8
我不確定如何使用requirejs模塊請求和定義指令。我們如何在requirejs模塊中定義一個angularjs指令?
這是我對含有指令的指令文件的代碼/ locationBtn.js
define(['Zf2NVIApp'], function (Zf2NVIApp) {
'use strict';
Zf2NVIApp.directive('locationBtn', function() {
return {
template: '<div></div>',
restrict: 'E',
link: function postLink(scope, element, attrs) {
console.log("we are in the location btn module");
element.text('this is the locationBtn directive');
}
};
});
});
這是代碼我main.js文件
require.config({
shim: {
},
paths: {
angular: 'vendor/angular',
jquery: 'vendor/jquery.min',
locationBtn: 'directives/locationBtn'
}
});
require(['Zf2NVIApp', 'locationBtn'], function (app, locationBtn) {
// use app here
angular.bootstrap(document,['Zf2NVIApp']);
});
是的,這確實起作用。 – 2013-02-26 21:36:47