angular.module('test', [])
.directive('microFrontEnd', function($rootScope) {
'use strict';
$rootScope.show = true;
return {
restrict: 'E',
templateUrl: '../template.html'
};
});
和模板:
<div ng-show="$rootScope.show">Hello man</div>
为什么$rootScope.show
未定义?错误在哪里?
答案 0 :(得分:0)
解决方案是将$rootScope.show
替换为$root.show
。有什么解释吗?