我正在使用angularjs+kendoui进行一个小项目。(我正在学习角度)
但是我发现ng-model只能以一种方式工作(它可以从控制器/模型填充到UI),但是当我更改UI时,它无法填充模型。
下面是一个简单的例子。
我在选项卡中有一个文本框。当我更新文本时,模型没有更新。我在选项卡外还有另一个文本框。当我更新文本时,模型已更新。请参阅下面的示例http://plnkr.co/edit/tknizoUTtheuOoAUZv4E?p=preview
Kendo 指令创建一个新作用域。你需要在你的ng模型中有'.。建议使用。
app.controller("myCtrl", function ($compile, $scope) {
$scope.o = {};
$scope.o.testText = 'hello'
$scope.o.testText2 = 'hello2'
});
在您看来
<div id="tabstrip" kendo-tab-strip>
<ul>
<li class="k-state-active">Tab 1</li>
<li>Tab 2</li>
</ul>
<div>
<input type="text" ng-model="o.testText" />
</div>
<div>
[Page 2]
</div>
</div>
<div>
<span>Tab Text </span></span><p>{{o.testText}}</p>
</div>
<span>Outside Tab Text </span>
<input type="text" ng-model="o.testText2" />
<p>{{o.testText2}}</p>
</body>
您可以在以下位置找到有关角度此功能的更多详细信息Angular 中的范围继承