[英]two divs in angular and I need to hide one div and display another when a button in div one is pressed
I have the following code. 我有以下代码。 I need to hide div 1 and display div2 when the button in div one is clicked.
单击div 1中的按钮时,我需要隐藏div 1并显示div2。 (In ANGULAR HTML5).
(在HTML5中)。 I have a JS file with controllers etc. at the moement I have two diffetent html template files and I call these as separate modal pop up.
我有一个带有控制器等的JS文件。当时我有两个不同的html模板文件,我称它们为单独的模式弹出窗口。 Now instead of two pop ups, I need to just show only one pop up but just display or hide content from one of the divs.
现在,我不需要只显示一个弹出窗口,而不必显示两个弹出窗口,而只显示或隐藏其中一个div的内容。
<div id="div1">
<button name ="click" click="ClickMe()"/>
</div>
<div id = "div2">
<p> Some content</p>
</div>
This should toggle displayToggled on click, and remove the div from which the button was clicked from the DOM. 这应该在单击时切换displayToggled,然后从DOM中删除从中单击按钮的div。
<div id="div1" ng-if="!displayToggled" >
<button name ="click" ng-click="displayToggled = true"/>
</div>
<div id = "div2" ng-if="displayToggled">
<p> Some content</p>
</div>
In your html 在你的HTML
<body ng-app="myApp" ng-controller="myctrl as ctrl">
<div id="div1" ng-show="ctrl.btn">
<button name ="click" ng-click="ctrl.btn=!ctrl.btn"/>
</div>
<div id = "div2" ng-show="!ctrl.btn">
<p> Some content</p>
</div>
</div>
in your controller 在您的控制器中
.controller('myctrl', function(){
this.btn = true;
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.