我是新来的Angular和Require,我的问题是关于下面的一段代码(我已经挂钩角度和要求,如果问我可以包括文件);自举开关元件未被初始化:Angular.js + require.js + jQuery插件自定义指令
define(['myapp.ui/module', function (module) {
module.directive('bootstrapSwitch', ['$parse', '$path', function ($parse, $path) {
return {
restrict: 'A',
replace: true,
link: function (scope, element) {
//load requirements for this directive.
console.log(element.bootstrapSwitch);
element.bootstrapSwitch();
}
};
return require([
'myapp.ui/switch/bootstrap-switch.min',
'css!myapp.ui/switch/bootstrap-switch.min'],
function() {
return {
restrict: 'A',
replace: false,
link: function (scope, element) {
//load requirements for this directive.
element.bootstrapSwitch();
}
};
});
}]);
}]);
我能看到正在加载的指令文件(上面的那个),但该元素没有初始化,我看不到bootstrap-switch.min.css和bootstrap-switch.min.js(我知道路径的工作,我敢肯定,我有一个问题sintax的地方。如果没有,请详细说明。任何帮助,将不胜感激!!!!
谢谢!
完美的解释和发现我的错误!谢谢 :) – Jose 2014-10-10 22:58:10