title: angularJS - nginit, how to get scope
body: <p><a href="https://jsfiddle.net/jzhang172/7c2zgkf0/1/" rel="nofollow">https://jsfiddle.net/jzhang172/7c2zgkf0/1/</a></p>
  
  <p>How do I set the initial value of select with angularJS?  </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var app = angular.module('myApp', []);
  
  app.controller('carCtrl',function($scope){
  $scope.cars={
  car01 : {brand : "Ford", model : "Mustang", color : "red"},
  car02 : {brand : "Fiat", model : "500", color : "white"},
  car03 : {brand : "Volvo", model : "XC90", color : "black"}
  
  }
  
  });</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>input.ng-invalid{
    background:red;
      transition:.4s;
  }
  input.ng-valid{
    background:#A3CBFF;
    transition:.4s;
  }
  input.ng-pending{
    border:1px solid red;
  }
  input{
      font-size: 30px;
      text-align: center;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"&gt;&lt;/script&gt;
  
  
  &lt;div ng-app="myApp" ng-controller="carCtrl" ng-init="selectCar='$scope.cars.car01'"&gt;
  &lt;p&gt;
  Please Select a Car
  &lt;/p&gt;
  &lt;select ng-model="selectCar" ng-options="x for (x,y) in cars" &gt;
  
  &lt;/select&gt;
  &lt;span&gt;Color: {{selectCar.color}}&lt;/span&gt;
  &lt;span&gt;Model: {{selectCar.model}}&lt;/span&gt;
  &lt;span&gt;Brand: {{selectCar.brand}}&lt;/span&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>