我有與來自另一個和代碼指令訪問的一個問題是低於如何從別人angularjs訪問指令?
app.module('myApp', [])
.directive('vikiQues', ['$http', '$compile', function($http, $compile){
return {
restrict : 'E',
scope : true,
controller : [
function(){
}
],
link : function(scope, iElement, iAttrs){
$http.get('getOutside/1')
.then(function(data){
iElement.html($compile($(data.data))(scope));
/*scope.addThere.find('div.please-wait').remove();
scope.questionList.push({
text : '',
options : []
});*/
});
}
};
}]).directive('vikiOption', ['$http', '$compile', function ($http, $compile) {
return {
restrict: 'E',
scope : true,
require : '^vikiQues',
link: function (scope, iElement, iAttrs, vikiQuesCtrl) {
$http.get('getInside/1')
.then(function(data){
var _ = $(data.data);
scope._opt = false;
iElement.html($compile(_)(scope));
if (scope.$parent.questionList[scope.$parent.totalQuestionCount-1].options.length > 2)
_opt = true;
scope.now = {
id : scope.$parent.questionList[scope.$parent.totalQuestionCount-1].options.length,
char : '',
text : '',
image : '',
removeable : scope._opt,
};
ques.now.options.push(scope.now);
});
}
};
}]);
我得到這個錯誤每次:angular.min.js:117錯誤:[$編譯:ctreq] http://errors.angularjs.org/1.5.7/ $編譯/ ctreq P0 = vikiQues & P1 = vikiOption
什麼有錯?
HTML代碼:
0" >
viki-ques和viki-option是來自php的模板。 如果刪除 iElement.html($編譯($(data.data))(範圍)); 代碼,我不能得到錯誤。我想我有錯誤。 ithink $ compile或scope提供這個錯誤。(幫助)
安置自己的HTML。 – dfsq
沒有足夠的信息來幫助。用這個問題創建演示,然後很容易找出問題。 – dfsq