{{}}正常,但ng-model不在同一位置。ng模型和角度表達式之間的區別 - {{}}
我使用HTML的如下
<body ng-app="crud">
Gray input fields will not be visible.
<div ng-controller="ctrl">
<input type="text" value="sdf" ng-model="asdf"/>
<h1 ng-model="asdf"></h1> <!-- this doesn't work-->
<h1>{{asdf}}</h1> <!-- this work-->
</div>
</div>
</body>
ASDF在這個定義JS應用這樣
var app = angular.module("crud", []);
app.controller("ctrl", ['$scope', function($scope) {
$scope.asdf="ankur";
}]);
有人能解釋爲什麼會這樣呢?
你應該使用'NG-bind',而不是'NG-model'單程結合 – z0mBi3