Javascript ng显示布尔值更改后不工作
我的导航栏中有一个Javascript ng显示布尔值更改后不工作,javascript,html,.net,angularjs,angularjs-ng-show,Javascript,Html,.net,Angularjs,Angularjs Ng Show,我的导航栏中有一个ng单击来更改布尔值并显示我的div。当我单击它时,布尔值会更改,但ng显示没有响应 这个html在我的布局文件中,而我正在使用的控制器在我的主体html文件中。当我把上面的html放在我的身体html文件中时,整个工作正常吗?会发生什么事?我没有从角度或其他任何地方得到错误。我的所有脚本都包含在我的布局文件以及我的angular应用程序定义中 布局文件中导航栏中的Html: <div class="navbar-collapse collapse" ng-control
ng单击
来更改布尔值并显示我的div。当我单击它时,布尔值会更改,但ng显示
没有响应
这个html在我的布局文件中,而我正在使用的控制器在我的主体html文件中。当我把上面的html放在我的身体html文件中时,整个工作正常吗?会发生什么事?我没有从角度或其他任何地方得到错误。我的所有脚本都包含在我的布局文件以及我的angular应用程序定义中
布局文件中导航栏中的Html:
<div class="navbar-collapse collapse" ng-controller="MoviesCtrl">
<ul class="nav navbar-nav">
<li class="active"><a href="index.html"><i class="icon-home icon-white"></i> Today</a></li>
<li ng-click="flipTwoDay()"><a><i class="icon-folder-open icon-white"></i> Two Days</a></li>
<li><a href="manager.html"><i class="icon-folder-open icon-white"></i> All</a></li>
</ul>
</div>
正文文件中的Html:
<div ng-show="twoDay.show">
<h1>{{tomorrow}}</h1>
<div ng-repeat="theat in data.Locations">
<div class="col-sm-6 col-lg-6">
<div class="dash-unit">
<dtitle>{{theat.Name}}</dtitle>
<hr>
<div ng-repeat="film in theat.Dates[tomorrow]">
{{film.title}}{{film.times}}
</div>
</div>
</div>
</div>
</div>
{{明天}
{{theat.Name}
{{film.title}{{film.times}}
位于cshtml文件正文底部的JavaScript
mabuse.page.moviesCtrl = function ($scope, $firebase) {
var ref = new Firebase("https://mabuse.firebaseio.com/");
// create an AngularFire reference to the data
var sync = $firebase(ref);
$scope.data = sync.$asObject();
var currentDate = new Date()
var day = currentDate.getDate()
var month = currentDate.getMonth() + 1
var year = currentDate.getFullYear()
if (day < 10) {
dat = '0' + day
}
if (month < 10) {
month = '0' + month
}
$scope.today = day + " " + month + " " + year;
day += 1;
$scope.tomorrow = day + " " + month + " " + year;
$scope.twoDay = {show : false};
$scope.flipTwoDay = function () {
$scope.twoDay.show = true;
// $scope.$digest();
console.log($scope.twoDay.show);
};
console.log($scope.tomorrow);
};
mabuse.page.moviesCtrl=function($scope,$firebase){
var ref=新的火基(“https://mabuse.firebaseio.com/");
//创建数据的AngularFire引用
var sync=$firebase(ref);
$scope.data=sync.$asObject();
var currentDate=新日期()
var day=currentDate.getDate()
var month=currentDate.getMonth()+1
var year=currentDate.getFullYear()
如果(第10天){
dat='0'+天
}
如果(月<10){
月份='0'+月份
}
$scope.day=日+月+年;
日+=1;
$scope.明天=日+月+年;
$scope.twoDay={show:false};
$scope.flipTwoDay=函数(){
$scope.twoDay.show=true;
//$scope.$digest();
log($scope.twoDay.show);
};
console.log($scope.明天);
};
代码看起来不错。无论如何,尝试ng if代替ng show。也只是为了测试更改:$scope.twoDay={show:false};至:$scope.twoDay.show=false;和,$scope.twoDay={};位置ng重复显示数据吗?通过查看您的代码,看起来像是两天。show变量不属于MoviesCtrl
(属于navbar。)@pankajparkar我也有同样的想法。我还发现了一件事,他在div中声明了ng controller=“MoviesCtrl”,并且正在关闭它。因此,ng controller=“MoviesCtrl”仅适用于该div部分。并非所有人都是这样。@Ved和其他东西为什么MoviesCtrl
定义为mabuse.page.MoviesCtrl
会有打字错误?@pankajparkar让我们看看。。他回答的是。。。