[英]angular directive not rendering
我試圖在我的應用程序中包含指令,但是即使基本指令也沒有呈現。 我究竟做錯了什么?
angularloader.js:
var main = angular.module('ngMain', [])
.directive('myScrollable', function () {
return {
restrict: 'AE',
template: '<h3>Hello World!!</h3>'
};
});
我的HTML:
<html ng-app dir="auto">
<head>
<meta name="viewport" content="width=device-width" />
<title>@Model.Title</title>
<script src="/Scripts/Libs/angular.js"></script>
<script src="/Scripts/Custom/angularloader.js"></script>
</head>
<body dir="auto">
<my-scrollable></my-scrollable>
</body>
</html>
也嘗試過使用標簽或屬性..
您應該在ng-app="moduleName"
使用模塊名稱
喜歡:
<html ng-app="ngMain" dir="auto">
如果您在變量中分配了角度模塊,則可以像下面這樣使用該變量:
var main = angular.module('ngMain', []);
main.directive('myScrollable', function () {
return {
restrict: 'AE',
template: '<h3>Hello Worlds!!</h3>'
};
});
您已經定義了模塊,但是忘記在ng-app =“ you module Name”中使用html。 您無需聲明變量main的另一件事就是,代碼也可以正常工作。
angular
.module('myModule', [])
.directive('myDir', function{
your code
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.