ng中使用的指令包括dond'不起作用
Directives that is used in ng-include doesn't work
我有如下自定义指令。
var fancySelectDirective = pluginDirecitvesModule.directive("custom-select",function(){
return {
restrict: 'C',
link: function (scope, element, attrs) {
element.fancySelect();
}
}
});
此指令用于模板中。当我用ng-include包含这个模板时,指令不起作用,即链接函数不被调用(我试图在控制台中调试)。但当我直接在页面中使用此模板时,该指令有效。我不明白为什么会出现这个问题。
我使用ng包括以下内容:
<div id="main_wrapper" ng-include="template.html"></div>
该指令在模板中使用如下:
<select class="custom-select">
这只是一个拼写错误customSelect
而不是custom-select
。
指令应被宣布为骆驼案;大写字母将替换为-
+小写字母,例如customSelect
将在html上写为custom-select
代码
var fancySelectDirective = pluginDirecitvesModule.directive("customSelect", function() {
return {
restrict: 'C',
link: function(scope, element, attrs) {
element.fancySelect();
}
}
});
希望这能帮到你,谢谢。
相关文章:
- electronic BrowserWindow的最小高度和宽度在hide()show()方法之后不起作用
- 监视函数从服务返回不起作用,但作用域函数起作用
- 幻灯片滚动javascript不起作用
- 简单的javascript在Shopify中不起作用
- Recaptcha在IE7和IE8中不起作用
- Ember Data DS.Model's set函数不起作用
- JsFiddle上的鼠标事件不起作用
- 我的AngularJS表达式没有'不起作用
- 点击按钮输入不起作用
- 面向对象的Javascript代码在IE7中不起作用
- 分部隐藏在jquery中不起作用
- 在phonegap应用程序内部重定向不起作用
- Array.length似乎不起作用;console.log则显示其他情况
- $ionicplatform内的$scope不;不起作用
- 我的javascript for循环不起作用
- Meteor-添加用户自定义字段的方法不起作用
- 为什么 .focus() 不起作用,而 .css(“color”,“red”) 在同一个选择器上起作用
- Textarea必需的attribut在javascript中不起作用
- 为什么javascript:void(0)在Firefox中不起作用
- ng中使用的指令包括dond'不起作用