Angularjs:2路绑定不能在包含的模板中工作
发布时间:2020-12-17 08:05:27 所属栏目:安全 来源:网络整理
导读:我想我在这里缺少一些简单(重要)的东西。我使用包含的模板,其中包含映射到某个值的输入: div ng-controller="Ctrl" div ng-include src="'template.html'"/div/div!-- template --script type="text/ng-template" id="template.html" input ng-model="test
我想我在这里缺少一些简单(重要)的东西。我使用包含的模板,其中包含映射到某个值的输入:
<div ng-controller="Ctrl"> <div ng-include src="'template.html'"></div> </div> <!-- template --> <script type="text/ng-template" id="template.html"> <input ng-model="testvalue" /> </script> 控制器: function Ctrl($scope) { $scope.testvalue= "initial value"; }? 警告$ scope.testvalue的值始终显示初始值,而不是更新的值(在输入时键入)。帮助我欧比湾你是我们唯一的希望。 小提琴:http://jsfiddle.net/h5aac/
这是绑定到原始而不是对象的常见的。字符串的值被传递,而不是对对象的引用。如果您使用对象而不是基元,则可以正常工作。在你的范围内这样的东西。
$scope.foo = {testvalue: "initial value"}; 见http://jsfiddle.net/h5aac/2/ 也: Using `ng-model` within a transcluded directive in AngularJS binding issue when a directive in a ngRepeat AngularJS – updating scope value with asynchronous response 我确定有更多… (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容