繁体   English   中英

带引导程序弹出窗口的角度ng-if不起作用

[英]angular ng-if with bootstrap popover not working

<div class="form-group" ng-if="firstname">
    <label>First Name</label>
    <input readonly type="text" class="form-control" id="first_name" ng-model="firstname" placeholder="First Name">
    <a href="" data-toggle="popover" data-placement="bottom" data-trigger="focus" data-content="User Name" class="glyphicon glyphicon-info-sign infottp"></a>
</div>

我正在使用上面的代码。 因此,我通过单击-info-sign glyphicon显示弹出窗口,我正在使用ng-if条件来显示/隐藏而不是ng-show和ng-hide。我的问题是当我使用ng-if时,弹出窗口不起作用。但是popover在ng-hide条件下工作,如果我删除ng-if条件。我的问题是为什么popover在ng-if条件下不工作。

知道了! 是, ng-if阻止呈现DOM元素,其中ng-show / ng-hide仅更改display css-poperty

请参阅Ang-if的角度文档的第一段

这是演示ng-if如何工作的示例

 var app = angular.module('myApp', []); app.controller('customersCtrl', function($scope, $http) { $scope.firstname = "Test Data"; }); 
 <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script> <body> <div ng-app="myApp" ng-controller="customersCtrl"> <div ng-if="lastname"></div> <div class="form-group" ng-if="firstname"> <label>First Name</label> <input readonly type="text" class="form-control" id="first_name" ng-model="firstname" placeholder="First Name"> <label>Last Name</label> <input readonly type="text" class="form-control" id="last_name" ng-model="lastname" placeholder="Last Name"> </div> </div> </body> 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM