Darold Davis
Darold Davis

Reputation: 247

AngularJS: Pass a JSON Object to a Modal

I have a modal to display some user information, much like a profile:

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

Here is the JSON object of the user information:

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

How do I display the JSON object into the modal div? Would my ng-controller go in the div? I've just been using AngularJS for the past 3 weeks and am still getting accustomed with its MVC.

Upvotes: 0

Views: 2410

Answers (1)

Jigar Patel
Jigar Patel

Reputation: 4615

It is really easy to have two way data binding in AngularJS. However, generally speaking, only scope data is available for the data binding. I would highly recommend you to go through the AngularJS tutorial series.

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

Just go through all first few pages of the documentation and you will find the basic information to get started. Your enthusiasm to get things done is understandable but reading documentation is equally important.

Currently for your problem here is the simple solution. http://plnkr.co/edit/JG1bDjZgp9gsSiKSEmJB

Upvotes: 2

Related Questions