これは私のアプリの設定です:
angular.module('myApp', ['myApp.directives', 'myApp.controllers', 'myApp.services']);
これは私のコントローラーです:
angular.module('myApp.controllers', [])
.controller('MainCtrl', function ($scope) {
$scope.name = 'world';
});
これは私の指示です:
var directives = angular.module('myApp.directives', []);
directives.directive("hello", function () {
return function (scope, elm, attrs) {
elm.text("hello, " + scope[attrs.name]);
};
});
これは私のhtmlです:
<div ng-controller="MainCtrl">
<h1 hello></h1>
</div>
問題は、Angular がディレクティブを次のようにレンダリングすることです。
こんにちは、未定義
それ以外の:
こんにちは世界
なにが問題ですか?