Monday 15 June 2015

javascript - How to get json data and construct a modal using Angular JS -


When I click on the View Details button, I want to request JSON data and then create a model view on the content Want to do

HTML:

  & lt; A href = "#" & gt; See details 1 & lt; / A & gt; & Lt; A href = "#" & gt; See details 2 & lt; / A & gt; & Lt; A href = "#" & gt; See Details 3 & lt; / A & gt;   

Get JSON:

  function myCtrl ($ scope) {$ http.get ('json / story.json'). Success (work) {Console.log (data); $ scope.story = data;}); }   

When a user clicks on a detailed button, then what is the best way to use the MyCtrl function to use angular.js? Apart from this, HTML is being printed using another controller. I hope there is no way to force clicks vs hard-coding IDs and links.

You can call ways in your controller like this:

  & Lt; A href = "#" ng-click = "getDetails ()" & gt; View Details & lt; / A & gt;   

and then in the controller:

  $ scope.getDetails = function () {$ http.get (...). Success (work) {$ scope.story = data;}); }    

No comments:

Post a Comment