AngularJS1.4.6

来源:互联网 发布:skycc软件 编辑:程序博客网 时间:2024/05/17 23:24

1、ng-init会使controller对应的初始化失效

2、有效:ng-show="myForm.myAddress.$error.email"

     无效:ng-show="myAddress.$error.email"

3、 <input type="email" ng-model="name" name="name1">
      <p>{{name}}</p>

      只有当name是合法数据时才会显示{{name}}

4、<select ng-model="selectedName">
            <option value="0">请选择</option>
            <option ng-repeat="x in names" value="{{x.id}}">{{x.name}}</option>
      </select>

      运行时发现没有默认值,必须初始化:$scope.selectedName='0',或者<select ng-model="selectedName" ng-init="selectedName='0'">

5、<select ng-model="selectedName" ng-init="selectedName=1" ng-options="x.id as x.name for x in names"></select>

     x.id是key,x.name是value