Javascript ng选项不适用于基本情况
我试图通过使用ng选项来构建一个极其简单的选择Javascript ng选项不适用于基本情况,javascript,angularjs,angularjs-ng-options,Javascript,Angularjs,Angularjs Ng Options,我试图通过使用ng选项来构建一个极其简单的选择 angular.module('foo', []).directive('listSelect', ['$injector', function(injector){ return { restrict: 'E', template: "<select ng-options='val as val for val in list'></select>", link: function(sc
angular.module('foo', []).directive('listSelect', ['$injector', function(injector){
return {
restrict: 'E',
template: "<select ng-options='val as val for val in list'></select>",
link: function(scope, elem, attrs){
scope.list = ['foo', 'bar', 'bazz'];
}
}
}]);
angular.module('foo',[])指令('listSelect',['$injector',函数(injector){
返回{
限制:'E',
模板:“”,
链接:功能(范围、要素、属性){
scope.list=['foo','bar','bazz'];
}
}
}]);
这个看似直截了当的指令无法呈现正确的下拉选项。为什么?
plunk:您选择的缺少型号
template: "<select ng-model='hier' ng-options='val for val in list'></select>"
link: function (scope) {
scope.list = ['foo', 'bar', 'bazz'];
scope.hier = scope.list[0];
}
模板:“
链接:功能(范围){
scope.list=['foo','bar','bazz'];
scope.hier=scope.list[0];
}
您选择的缺少型号
template: "<select ng-model='hier' ng-options='val for val in list'></select>"
link: function (scope) {
scope.list = ['foo', 'bar', 'bazz'];
scope.hier = scope.list[0];
}
模板:“
链接:功能(范围){
scope.list=['foo','bar','bazz'];
scope.hier=scope.list[0];
}
您选择的缺少型号
template: "<select ng-model='hier' ng-options='val for val in list'></select>"
link: function (scope) {
scope.list = ['foo', 'bar', 'bazz'];
scope.hier = scope.list[0];
}
模板:“
链接:功能(范围){
scope.list=['foo','bar','bazz'];
scope.hier=scope.list[0];
}
您选择的缺少型号
template: "<select ng-model='hier' ng-options='val for val in list'></select>"
link: function (scope) {
scope.list = ['foo', 'bar', 'bazz'];
scope.hier = scope.list[0];
}
模板:“
链接:功能(范围){
scope.list=['foo','bar','bazz'];
scope.hier=scope.list[0];
}