title: Passing data from MVC model to an Angular Controller
body: <p>I have an angular controller inside a mvc view. I need to pass data coming from the MVC model into the angular controller. Currently a developer is using ngInit directive to pass this data. </p>
  
  <p><strong>In xxx.cshtml</strong></p>
  
  <pre><code>&lt;div ng-controller="AssessmentController" ng-init   ="Init('@Model.Status','@Model.ARN','@Model.AssessmentID','@Model.AssessorID',@Model.Contents, @Model.Date_of_Assessment.ToJsonTicks(),'@Model.HouseReferenceID',@Newtonsoft.Json.JsonConvert.SerializeObject(Model.House))"&gt;
  </code></pre>
  
  <p>I pointed out that according to Angular documentation ngInit directive is not to be used to to initialize controllers. <a href="https://docs.angularjs.org/api/ng/directive/ngInit" rel="nofollow">https://docs.angularjs.org/api/ng/directive/ngInit</a></p>
  
  <p>Instead what I suggested was to send the ID in ngInit directive and</p>
  
  <pre><code>&lt;div ng-controller="AssessmentController" ng-init   ="Init('@Model.AssessmentID'"&gt;
  </code></pre>
  
  <p>Then after that use $http [<a href="https://docs.angularjs.org/api/ng/service/" rel="nofollow">https://docs.angularjs.org/api/ng/service/</a>$http] service to get the remainder of data from the Angular controller.</p>
  
  <p>The developer is refusing my idea saying it's faster to just send all the data through ngInit directive instead of having to do another call to get the data inti the Angular controller.</p>
  
  <p>What do you guys think about this scenario? The only point I have right now is that this code is FUGLY and it not according to standards. How would you convince a developer to follow the path I suggested. Or am I completely wrong here?</p>
  
  <p>If you had to pass data from the MVC model into the Angular controller how would you do it?</p>