只有在指令中更改时,AngularJS切换标头才有效

时间:2014-07-24 01:18:16

标签: javascript angularjs

我有以下标记:

<div class="schedule">  
    <!-- Header info -->
    <div class="row">
        <!-- Schedule title -->
        <div class="title" ng-click="toggleHeader()">
            <span ng-hide="isScheduleVisible">{{ schedule.name }} (Open to View)</span>
            <input ng-model="schedule.name" class="schedule-name" ng-show="isScheduleVisible"/>
        </div>

        <!-- Action menu items go here -->
        <div class="actions" ng-show="isScheduleVisible"></div>
    </div>

    <!-- Schedule Info -->
    <div class="row" ng-show="isScheduleVisible">
        <!-- This is the time on the left of the table -->
        <div id="times"></div>

        <!-- Conditions for the Schedule -->
        <div id="conditions"></div>

        <!-- Shifts of the Schedule -->
        <div class="shifts"></div>
    </div>
</div>

我想通过单击“标题”来切换内容(请参阅下面的打开/关闭状态快照)。现在,正如您所看到的,我在控制器中调用函数toggleHeader(),它所做的就是:

$scope.toggleHeader = function()
{
    $scope.isScheduleVisible = ! $scope.isScheduleVisible;
}

我想用ng-click="isScheduleVisible = !isScheduleVisible"替换它。但是,这不起作用。这只会切换标题(灰色横幅)而不是实际内容(计划)。

为什么?!

enter image description here

0 个答案:

没有答案