我是angular的新手,并尝试使用mmenu创建一个指令,但不幸的是插件无法工作。任何帮助都是最好的。
我创建了一个plunker。
谢谢,
var App = angular.module('wdapp', []);
App.controller('results', function($scope, $http) {
$http.get('data.json')
.then(function(res){
$scope.bookmarks = res.data;
});
});
App.directive("mmenu", function()
{
return {
restrict: "A",
link: function(scope, element, attrs){
$(element).mmenu({
offCanvas: false,
//counters: true,
searchfield: {
add: false,
//search: false,
},
header: {
add: true,
update: true,
title: "Navigation"
},
navbar: {
title: ""
},
});
}
};
});发布于 2016-07-18 08:37:42
我对mmenu了解不多,但是根据你的柱塞,最明显的问题是你对restrict: 'A'的使用。这是针对属性指令的。
您需要将其更新为restrict: 'E'或restrict: 'EA',以便将其用作element指令;原样:<mmenu></mmenu>
有关restrict属性的更多信息:AngularJS: API: $compile
https://stackoverflow.com/questions/38426993
复制相似问题