0
我已經有一個指令(appView),並且有一些html可以通過templateUrl加載。到目前爲止,我需要向另一個指令(appView)正在使用的模板添加一個自定義指令。如何將自定義指令包含在角度js中的另一個自定義指令的模板(html)
請參閱下面的代碼,它不按預期工作。有關這方面的任何幫助,我可以如何讓這項工作?
View.html(模板)
<div>
<div class="dragdrop" id="dropzone" dropzone> //here is my custom directive
<div class="fileUpload btn btn-primary">
<span>UPLOAD ASSETS</span>
<input id="dzFile" type="file" class="upload" />
</div>
</div>
</div>
角JS
var appModule = angular.module("Newapp", []);
appModule.directive("appView", appView);
function appView(){
var directive = {
restrict: 'E',
templateUrl: 'app/View.html'
};
return directive;
}
appModule.directive("dropzone", function(){ //This is added to the View.html as attribute(see above html code with **)
var directive = {
restrict: 'A',
link: FullDragDrop
};
return directive;
});
function FullDragDrop(){
console.log("soemthing goes here");
}
我怎樣才能使這個可能,請?
爲什麼** **懸浮窗,而不是你的懸浮窗裏面View.html? – Nicolas2bert
@NicolasHumbert,這是通知誰引用,多數民衆贊成它。它只是dropzone – User123
@ User123你在找什麼?你的代碼正在工作。你可以檢查一下這個笨蛋,看看。顯示文字「這裏有東西」。 http://plnkr.co/edit/vwIrM7D402juEDDHDKbC?p=preview –