AngularJS:将JSON对象传递给模态

时间:2013-02-01 22:27:23

标签: json angularjs modal-dialog

我有一个模式来显示一些用户信息,就像个人资料一样:

<!-- Modal -->
 <div id="modalBoy-z" class="modal hide fade in" style="display: none; ">  
   <div class="modal-header">  
     <a class="close" data-dismiss="modal">×</a>  
     <h3>User Profile</h3>  
 </div>
    <div ng-controller="">  
      <h3>Name: </h3>  
      <h3>Email: </h3>
      <h3>Join Date: </h3>
      <h3>Role: </h3>
      <h3>Status: </h3>
    </div>  
    <div class="modal-footer">  
     <a href="#" class="btn" data-dismiss="modal">Close</a>  
    </div> 

以下是用户信息的JSON对象:

{
    "id": "8311...",
    "meta": {
      "created": 1355860257840,
      "updated": 1355860257840
    },
    "profile": {
      "id": "https://project.dev:0000/profiles/admin",
      "type": "Profile",
      "vocSlug": "admin",
      "email": "admin@getsomething.com",
      "label": "System Administrator",
      "vocRole": [
        "role_administrator",
        "system_administrator",
        "profile_administrator"
      ],
      "Status": "active"
    }
  },

如何将JSON对象显示到模态div中?我的控制器会进入div吗?我在过去的3周里一直在使用AngularJS,但我仍然习以为常 与MVC。

1 个答案:

答案 0 :(得分:3)

在AngularJS中实现双向数据绑定非常容易。 但是,一般来说,只有范围数据可用于数据绑定。 我强烈建议您阅读AngularJS教程系列。

http://docs.angularjs.org/tutorial/

只需浏览文档的前几页,您就会找到入门的基本信息。您对完成工作的热情是可以理解的,但阅读文档同样重要。

目前您的问题是这个简单的解决方案。 http://plnkr.co/edit/JG1bDjZgp9gsSiKSEmJB

相关问题