【发布时间】:2016-08-04 20:17:15
【问题描述】:
我正在使用引导程序制作一个角度下拉列表。我创建了一个指令,用户从下拉列表中选择一个菜单选项并提醒用户。
我在这里创建了一个 plnkr
http://plnkr.co/edit/tw3O5ihT7YB79BcAGlsh?p=preview
(function() {
'use strict';
angular.module('plunker').directive('exportData', exportData);
function exportData() {
var controller = function() {
var vmd = this;
vmd.exportAction = [{
id: 1,
action: 'Export all -> excel',
visble: true
}, {
id: 2,
action: 'Export selected -> excel',
visble: true
}, {
id: 0,
action: '',
visble: true,
divider: true
}, {
id: 3,
action: 'Export all -> pdf',
visble: true
}, {
id: 4,
action: 'Export selected -> pdf',
visble: true
}];
function activate() {} //activate
activate();
vmd.selectedExport = function(action) {
alert("you selected " + action.action);
};
} //controller
return {
restrict: 'EA',
// scope: {
// datasource: '=',
// },
controller: controller,
controllerAs: 'vmd',
templateUrl: 'exportData.html',
bindToController: true
//link: function ($scope, element, attrs) {
// });
};
};
}());
任何想法,谢谢。
【问题讨论】:
标签: javascript angularjs