Dis*_*sha 1 html javascript angularjs
我在我的应用程序中使用isteven-multi-select进行多项选择.一切正常,直到我在另一个模板中添加isteven-multi-select div.在那种情况下,我在输出模型中没有得到任何值.
在这里,我将其添加到另一个模板中
<body ng-controller="MainCtrl">
<div ng-include="'test.html'"></div>
<button ng-click="a()">Print output</button>
<p>selected scope: {{ selectedScope }}</p>
</body>
Run Code Online (Sandbox Code Playgroud)
test.html -
<section>
<div>
<div isteven-multi-select
input-model="scopes"
output-model="selectedScope"
button-label="name"
item-label="name"
tick-property="ticked"
>
</div>
</div>
</section>
Run Code Online (Sandbox Code Playgroud)
ng-include创建继承所有父范围属性的新范围.所以你应该将父母传递selectedScope给output-model属性:
<section>
<div>
<div isteven-multi-select
input-model="scopes"
output-model="$parent.selectedScope"
button-label="name"
item-label="name"
tick-property="ticked"
>
</div>
</div>
</section>
Run Code Online (Sandbox Code Playgroud)
您可以阅读本文以更好地理解范围.