0
获得价值回我有这个指令无法从指令
app.directive('countrySelect', function (Country) {
return {
templateUrl: 'template/directives/countryselect.html',
restrict: 'E',
scope: {
selectedValue: '='
},
link: function (scope) {
Country.success(function (data) {
scope.countries = data;
});
}
}
});
我的模板
<select chosen
data-placeholder="Country"
search-contains="true"
ng-model="selectedValue"
ng-options="name as country.name for country in countries">
<option value=""></option>
</select>
我设置的模式成为了selectedValue,但我只得到了一个未定义回来时,我尝试console.log它。
此处,我用我的指示
<country-select selected-value="custCtrl.editForm.country"></country-select>
和控制台登录变量custCtrl.editForm.country只是给出不确定的HTML。
我以为“=”是双向数据绑定? 我错过了什么?
谢谢
您传递给指令的变量必须是一个对象。你有没有确定是这样? –