在我的主要布局中,我有一个标题,例如:
<h1>{{ heading }}</h1>
我可以使用以下方法将其设置为控制器中的各种静态值:
$rootScope.heading = 'My Heading';
但是,如果我尝试从资源创建动态标题,则其为空白:
app.controller('ShowAccountController', function($scope, $rootScope, $state, $stateParams, Account) {
$scope.account = Account.get({ id: $stateParams.id });
$rootScope.heading = $scope.account.name;
});
帐户变量肯定设置在那里(通过控制台检查)所以我有点难过为什么标题没有值?