-1
單擊由angularjs指令生成的手風琴時,出現以下錯誤。我無法真正找到任何線索,爲什麼這可能發生,除了它與動態創建的內容有關。這些線索告訴我在我的angularjs控制器中再次調用基礎。我錯過了什麼?foundation 5在angularjs指令中引發異常拋出異常
Unhandled exception at line 58, column 7 in
http://localhost:58753/Scripts/foundation/foundation.js
0x800a139e - JavaScript runtime error: SyntaxError
這發生在這裏
var S = function (selector, context) {
if (typeof selector === 'string') {
if (context) {
var cont;
if (context.jquery) {
cont = context[0];
if (!cont) return context;
} else {
cont = context;
}
return $(cont.querySelectorAll(selector));
}
return $(document.querySelectorAll(selector));
}
return $(selector, context);
};
我的模板
<dl class="accordion" data-accordion>
<dd ng-repeat="x in myCollection | filter: { ParentId :'!', Checked : true }">
<a href="#{{x.Id}}"> {{x.Description}}</a>
<div id="{{x.Id}}" class="content">
asdf
</div>
</dd>
</dl>
我的指令
var myApp = angular.module('myApp', []);
function myDir() {
"use strict";
function link(scope, elem, attr) {
}
function ctrl(scope) {
};
ctrl.$inject = ['$scope'];
var ddo = {
restrict: 'E',
transclude: false,
replace: false,
templateUrl: '/AngularTemplates/ScopePicker',
link: link,
controller:ctrl,
scope: {
myCollection: '='
}
};
return ddo;
}
myApp.directive('myDir', myDir);
我控制器
function MyCtrl(scope,http) {
http.get('/api/somethingcool').success(function (result) {
scope.foo = result; // gets passed into myColleciton for the directive
angular.element(document).foundation();
});
}