1
<div id="content"><div>
我想插入我的指令。我做
html = $compile('<test></test>')($scope);
$("#content").html(html);
我的指令:
app.directive("test", function ($compile, $route) {
return {
restrict: "E",
templateUrl: "/Templates/test.html",
controller: function ($scope, $location) {},
controllerAs: "page"
};
});
「/Templates/test.html」:
... some code ...
<category></category>
指令測試和類別從服務器上傳一些數據。 由於某些原因類別工作,但測試不。 有人知道爲什麼嗎? 謝謝
首先你爲什麼要注入你的像這樣在您的#內容?如果您想要相應地將內容更改爲應用程序的當前路徑/狀態,請使用ngRoute(native)或ui-router(第三方庫)。除了指令外,你不應該在其他事情中使用$/augular.element。 –
Walfrat