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
未定义?错误在哪里?
解决方案是用$root.show
替换$rootScope.show
。对此有什么解释吗?