javascript - AngularJS,当 bool 值改变时 ng-show 不起作用

标签 javascript angularjs ng-show

AngularJS 中的 HTML 页面。 当 bool 值设置为真时,我的 ng-show 不会显示 div。

这是我的 HTML 文件:

<div class="container">
<div ng-if="!query" ng-hide="editBoolean">
    <h3>{{article.id}} - {{article.title}}</h3>
    <h4 ng-bind-html="article.text"></h4>
    <button ng-click="edit(true)">Endre tekst</button>
</div>

<div ng-show="editBoolean">

    <style>
    .ta-editor { 
        min-height: 300px; 
        height: auto; 
        overflow: auto; 
        font-family: inherit; 
        font-size: 100%; 
    } 
    </style> 

    <input type="text" ng-model="article.title" value="{{article.title}}">

    <div text-angular="text-angular" ng-model="article.text"></div>
    <button ng-click="update(article.text, article.title)">Lagre</button>
    <button ng-click="edit(false)">Avbryt</button>

</div>

<div ng-if="query">
    <h3>{{query}}</h3>
</div>  

这是我的 controller.js 文件:

 // Article controller
wikiControllers.controller('articleController', ['$scope', 'articleService',     '$routeParams', '$sanitize', 
  function($scope, articleService, $routeParams, $sanitize){
$scope.editBoolean = false;
$scope.edit = function(editValue){
  this.editBoolean = editValue;
  console.log(this.editBoolean);
};
  }]);

当我有 console.log 我的 booleanfil 时,它显示 true(值已更改)

最佳答案

这个:

this.editBoolean = editValue;

应该是:

$scope.editBoolean = editValue;

关于javascript - AngularJS,当 bool 值改变时 ng-show 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21160744/

相关文章:

angularjs - 根据 $scope 变量值显示元素

javascript - ng-show 不适用于 Angular 项目

javascript - “递归太多”-Typescript 中的错误

javascript - 使用 css 类更改所有元素的颜色

javascript - bxslider 移动第一张幻灯片

javascript - 有哪些基于 Angularjs 的客户端框架?

javascript - 如何在 AngularJS 中显示具有用户身份验证的按钮?

javascript - 为什么flow在使用instanceof时会给出uncovered code warning?

html - 使用 AngularJS 的动态内联 CSS

internet-explorer - Internet Explorer 和 Angular JS