我试图通过依赖 ng-options 来构建一个非常简单的选择。
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'];
}
}
}]);
这个看似直截了当的指令未能呈现正确的下拉选项。为什么?