javascript - ng 类条件改变但不应用新样式

标签 javascript css angularjs ionic-framework

我正在尝试根据 ng-class 的条件更改 Ionic 应用程序的 Pane 的背景,如下所示。手动更改代码中的条件并刷新服务页面效果很好。从输入更改条件不起作用。由于我使用的是 native Angular Directive(指令),我猜摘要循环应该自动运行?这可能是什么问题?

<body ng-app="starter" >

    <ion-pane ng-controller= "CardsCtrl" ng-class = " 1 < {{hello || 0}} ?'background1':'background2'">
      <ion-header-bar class="bar-stable">
        <h1 class="title">Ionic Blank Starter</h1>
      </ion-header-bar>
      <ion-content  scroll = "false">
     <div class = "item item-input">
       <input type="number"  name="" placeholder="Do sometthing awesome Fitz!" ng-model = "hello">
     </div>

//Checking ng-model binding here
     {{hello}}


      </ion-content>
    </ion-pane>
  </body>

最佳答案

您可以提供表示对象、数组或字符串的表达式,也可以直接向 ngClass 提供对象或数组。

看起来您想要使用一个对象。

这是一个对象,当hello大于0时,将应用类“background1”,当hello小于等于0时,将应用“background2”被应用

ng-class="{background1: hello > 0, background2: hello <= 0}"

关于javascript - ng 类条件改变但不应用新样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41369437/

相关文章:

javascript - 文件夹结构 Angularjs 不知道在哪里加载 javascript 文件

Javascript 模运算符的行为与其他语言不同

javascript - jQuery 仅将鼠标悬停在图像内容上而不是 Alpha

javascript - 当我单击不同页面应用程序中页眉中的超链接时,如何向下滚动到页脚

javascript - 在不使用 &lt;input type ="text"> 的情况下创建输入文本框

javascript - Angular 1.6 ng-repeat 不显示搜索结果

javascript - Word 文档的 pdf.js 模拟

javascript - 在网页中创建交互式 map

css - 在 wordpress 的 php 文件中查找标签

javascript - Angular Http put 方法在传递数据时出错(服务器期望表单 param )