angularjs - The most Angular-y way of pre-loading data into $scope -


The part of my application is a complete AJAX and some traditional posts are reloaded. Receiving data in $ scope is a trivial task using $ http , but what happens when data is available for the template during page load (General MVC The way in which everyone knows the fact after using AJAX?

Consider the following part of the code:

  
ng-repeat = "address Address "& gt; {{address.address1}} {{address.city}}, {{address.state}} {{address.zip}}

I generate 100 dynamic in $ scope.addresses without using AJAX How to go about loading the address?

"post-text" itemprop = "text">

For your "inline" controller, The easiest way to use the input will be:

  @Model SampleViewModel ... & lt; div ng-controller = "SampleCtrl" ng-init = "adresses =@Model.AdressesList" Another approach is displayed:  
  & lt; script> function SampleCtrl ($ scope) {$ scope.adresses = @ Html.Raw (Jason. Encode (model)); ...} & lt; / Script & gt; & Lt; Div ng-controller = "SampleCtrl" ng-repeat = "address address" & gt;  

Comments

Popular posts from this blog

c# - SignalR: "Protocol error: Unknown transport." when navigating to hub -

class - Kivy: how to instantiate a dynamic classes in python -

java - Algorithm negotiation fail SSH in Jenkins -