javascript - 如何使用 AngularJS 将数据传递到不同的页面?

标签 javascript angularjs

<分区>

对 angularJS 很陌生,试图将信息从一个页面传递到另一个页面。

目前此 Controller 以表格格式显示客户列表,其中一列是“更多信息”。

 ** 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> 
 ...

Controller :

** 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'}];}]);

我想要的是,当用户从表格中为一位客户单击“更多信息”时,它应该转到一个新页面,显示有关该客户的所有信息...

不确定新页面需要什么,但我猜它需要一个新 Controller :

  ** 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

关于javascript - 如何使用 AngularJS 将数据传递到不同的页面?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38124635/

相关文章:

javascript - 单击时显示隐藏 youtube 视频

javascript - 使用 JQuery 查找和复制图像

javascript - CakePHP 和 AngularJS - {{$index}} 的评估

javascript - 分析 `if(x)` VS `if(x===undefined)`

javascript - FabricJs 自定义属性 SVG 奇怪的行为

javascript - 在指令中,处理对用户定义的方法名称的调用

javascript - 如果需要重要的变量和参数,如何使 Angular 应用程序安全?

javascript - AngularJS 指令到指令通信

javascript - ng-model 在 ng-include 中不起作用

javascript - 用户交互后取消滚动