如何使用AngularJS将数据传递到不同的页面
How to pass data to different page using AngularJS?
对于angularJS来说,这是一个全新的东西,它试图将信息从一个页面传递到另一个页面。
当前该控制器以表格格式显示客户列表,其中一列为"More info"。
** adminSearch.html **
<div ng-controller="adminSearch">
...
<tr ng-repeat-start="custObj in customers | filter:custSearch">
<td> {{custObj.id}} </td>
<td> {{custObj.name}} </td>
<td> <a href="#"> More Info </a></td>
</tr>
...
控制器:
** adminSearch.js **
app.controller('adminSearch', ['$scope', function($scope) {
$scope.customers = [{id:1, name:'John', email:'John@example.com', phone:'555-1276', account:123456, mylH: '1'},
{id:2, name:'Mary', email:'Mary@example.com', phone:'800-BIG-MARY', account:123456, mylH: '1'},
{id:3, name:'Mike', email:'Mike@example.com', phone:'555-4321', account:123456, mylH: '0'}];}]);
我想要的是当用户点击"更多信息"从表中的一个客户,它应该去一个新的页面,显示有关该客户的所有信息…
不确定新的页面需要什么,但我猜它需要一个新的控制器:
** customerInfo.html **
<div ng-controller="customerInfo"> ... </div>
** customerInfo.js **
app.controller('customerInfo', ['$scope', function($scope) {
}]);
谢谢你的帮助是提前!
根据我的理解,您需要从一个HTML文件导航到另一个HTML文件,并传递该页面的客户详细信息。那么我建议使用ui router来浏览页面。请参考此链接https://scotch.io/tutorials/3-simple-tips-for-using-ui-router
相关文章:
- AngularJS$q承诺使用socket.io
- AngularJS-ng使用字符串索引在数组上重复
- AngularJS:如何使用java脚本函数更改跨度的ng-show条件
- 如何在angularjs中使用mailgun发送电子邮件
- 在AngularJS中使用多个主题的最佳方式是什么
- AngularJS无法使用translate值正确翻译
- 何时在AngularJS中使用$injector
- AngularJS:如何使用ng-include将javascript文件加载到部分中
- 在angularJS中使用模态窗口时,在控制器之间共享对象数组
- 如何在AngularJs中使用带有ng repeat的Regex
- 在AngularJS中使用$http.get检索JSON时出现错误400
- AngularJS:在使用嵌套的JQuery Sortables时保持Dom和Model同步
- 如何在 AngularJS 中使用自动完成功能
- AngularJS/Javascript:使用运算符对字符串进行排序
- 在 AngularJS 中使用不同的母版视图页进行状态
- 在angularJS中使用split()时无法编辑输入
- AngularJS在使用值作为值语法时选择不绑定
- AngularJs:如何使用ng点击来显示模式引导
- 如何在AngularJS中使用该函数之外的变量
- 在angularjs中使用ng repeat时扩展$index的范围