数组模型未正确绑定到视图

时间:2014-06-18 21:56:53

标签: angularjs

我有问题让我的angularjs app模型正确绑定到视图。

我在控制器中有这些方法来启用/禁用单个市场信息的编辑:

$scope.shopEditing = function (marketplaceId) {

    if ( ! $scope.settings) {
        return false;
    }
    return $scope.shopEditingRegistry[marketplaceId];
};



$scope.toggleShopEditing = function (marketplaceId) {

    if ( ! $scope.settings) {
        return;
    }
    $scope.shopEditingRegistry[marketplaceId] = ! $scope.shopEditingRegistry[marketplaceId];
};

然后,在启用特定市场的编辑时,应该隐藏的视图:

        <div ng-repeat="shopInformations in settings.shops.list">

            <div class="line" ng-hide="{{shopInformations.isShopConnected || shopEditing(shopInformations.marketplaceId)}}">
                {{marketplaceName(shopInformations.marketplaceId)}} shop not connected
                <a class="button buttonGrayThin" ng-click="toggleShopEditing(shopInformations.marketplaceId)">Add</a>
            </div>
        </div>

问题是当我点击连接到toggleShopEditing()的按钮时,模型会成功更新,正确调用shopEditing(),但视图没有正确刷新。

&#39; div class =&#34; line&#34; &#39;没有隐藏。

我变得疯了。知道为什么会这样吗?

非常感谢!

1 个答案:

答案 0 :(得分:0)

根据@charlietfl的建议,删除ng-hide中的{{}}就足够了。