Javascript 在不同的控制器Angularjs中重写变量
我第一次使用ng show=“splash”,但即使在第二个控制器中,加载程序也会出现。为什么?我试图将其设置为false,但似乎不起作用 仅当$state处于活动状态时,我的secondCtrl才处于活动状态Javascript 在不同的控制器Angularjs中重写变量,javascript,angularjs,Javascript,Angularjs,我第一次使用ng show=“splash”,但即使在第二个控制器中,加载程序也会出现。为什么?我试图将其设置为false,但似乎不起作用 仅当$state处于活动状态时,我的secondCtrl才处于活动状态 app.controller('mainCtrl', ['$scope', '$http', function($scope, $http){ $scope.splash = true; }]); app.controller('secondCtrl', ['$scop
app.controller('mainCtrl', ['$scope', '$http', function($scope, $http){
$scope.splash = true;
}]);
app.controller('secondCtrl', ['$scope', function($scope){
$scope.splash2 = true;
$scope.splash = false;
}]);
这是一张工作票
我有一个嵌套控制器示例和一个兄弟控制器示例。他们都按预期工作
控制器:
function MyCtrl($scope) {
$scope.splash = true
}
function MyCtrl2($scope) {
$scope.splash = false;
}
<div ng-controller="MyCtrl">
<p ng-show="splash">Splash 1</p>
<div ng-controller="MyCtrl2">
<p ng-show="splash">Splash 2</p>
</div>
</div>
<div ng-controller="MyCtrl">
<p ng-show="splash">Splash3</p>
</div>
<div ng-controller="MyCtrl2">
<p ng-show="splash">Splash 4</p>
</div>
部分:
function MyCtrl($scope) {
$scope.splash = true
}
function MyCtrl2($scope) {
$scope.splash = false;
}
<div ng-controller="MyCtrl">
<p ng-show="splash">Splash 1</p>
<div ng-controller="MyCtrl2">
<p ng-show="splash">Splash 2</p>
</div>
</div>
<div ng-controller="MyCtrl">
<p ng-show="splash">Splash3</p>
</div>
<div ng-controller="MyCtrl2">
<p ng-show="splash">Splash 4</p>
</div>
飞溅1
飞溅2
Splash3
飞溅4
这个问题不清楚。你能解释一下你想要实现什么,并展示相关的html吗?