2017-08-07 64 views
0

假設我有這個文本標籤的一部分:嵌套的標籤或如何指定顯示標籤

<label>This is a text. This is another text.</label> 

如何,可以指定第二句應只顯示當布爾值爲true 。像這樣:

<label This is a text.</label> 
<label ng-hide="myctrl.showSecondText">This is another text</label> 

如果ng-hide的值爲true,我想在同一行顯示第二個短語。

回答

0

例如,您可能會在span標籤 中獲得第二個短語,並在其上添加ng-hide。

+0

它沒有被顯示在同一行,但下面:'<標籤這是一個文本。 ' – YourReflection

+0

@YourReflection但你可以使用:

0

使用ng-show

<label ng-show="ctrl.showSecondText">This is another text</label> 

var myapp = angular.module('myApp',[]); 
 
myapp.controller('myCtrl',function($scope){ 
 
    var ctrl = this; 
 
    ctrl.showSecondText = true; 
 
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script> 
 
<body ng-app="myApp" ng-controller="myCtrl as ctrl"> 
 
<label>This is a text.</label> 
 
<label ng-show="ctrl.showSecondText">This is another text</label> 
 
</body>