嵌套的标签或如何指定显示标签
问题描述:
假设我有这个文本标签的一部分:嵌套的标签或如何指定显示标签
<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,我想在同一行显示第二个短语。
答
例如,您可能会在span标签 中获得第二个短语,并在其上添加ng-hide。
答
使用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>
它没有被显示在同一行,但下面:' ' – YourReflection
@YourReflection但你可以使用: –