我在做一個非常簡單的指令,這是app.js代碼很簡單角指令使用限制,以「C」不工作
var myApp = angular.module('myApp', [])
myApp.directive('layout-top', function() {
return {
restrict: 'C',
templateUrl: 'templates/layout__top.template.html'
}
})
這是模板加載:
<div class="layout__top">
<div class="top__left">
Some kind of content
</div>
</div>
而且THI,是html代碼...
<!DOCTYPE html>
<html lang="en" ng-app="myApp" ng-strict-di>
<head>
<meta charset="UTF-8">
</head>
<body ng-controller="MainCtrl">
<div class="layout__wrapper">
<!-- TOPBAR GOES HERE -->
<div class="layout-top"></div>
</div>
<script type="text/javascript" src="bower_components/angular/angular.js"></script>
<script type="text/javascript" src="js/app.js"></script>
</body>
</html>
當我嘗試使用restric到A或E可以工作,但不能和班級一起工作。爲什麼?
難道不該
? –我認爲Caleb可能是正確的,下劃線應該是一個連字符... – hally9k
也是一個雙下劃線,可以與單一的 – charlietfl