Angularjs:2路绑定不能在包含的模板中工作

我想我在这里缺少一些简单(重要)的东西。我使用包含的模板,其中包含映射到某个值的输入:
<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

我确定有更多…

相关文章

ANGULAR.JS:NG-SELECTANDNG-OPTIONSPS:其实看英文文档比看中...
AngularJS中使用Chart.js制折线图与饼图实例  Chart.js 是...
IE浏览器兼容性后续前言 继续尝试解决IE浏览器兼容性问题,...
Angular实现下拉菜单多选写这篇文章时,引用文章地址如下:h...
在AngularJS应用中集成科大讯飞语音输入功能前言 根据项目...
Angular数据更新不及时问题探讨前言 在修复控制角标正确变...