gpt4 book ai didi

javascript - 隐藏和显示表单(Angular JS)

转载 作者:行者123 更新时间:2023-12-03 07:31:57 25 4
gpt4 key购买 nike

我的按钮不起作用,在我将字符串显示在控制台上的函数中,控制台显示,但我不明白的是为什么他进入该函数但不将“isVisible”的状态更改为显示和隐藏...

索引代码如下:

<div ng-controller="ReviewController as reviewCtrl" ng-submit="reviewCtrl.addReview(product)">
<button class="btn-warning" ng-click="reviewCtrl.ShowHide()">Deixe uma review!</button>
<form name ="reviewForm" ng-show ="reviewCtrl.isVisible">

<h2 style="color: black; font: status-bar; font-size: large">Sua Review: </h2>
<p>

<blockquote style="margin-bottom: 0%; padding-bottom: 0%">

<b><span class="glyphicon glyphicon-star">{{reviewCtrl.review.stars}}</span></b>
<b>{{reviewCtrl.review.author}}</b>
<p>
<p>
<cite>{{reviewCtrl.review.body}}</cite><p>
<hr>
</blockquote>
<p>
<h4 style="color: black; font: status-bar; font-size: x-large">Adicionar uma Review: </h4>

<p>
<select ng-model="reviewCtrl.review.stars">
<option value="1">1 Star</option>
<option value="2">2 Stars</option>
<option value="3">3 Stars</option>
<option value="4">4 Stars</option>
<option value="5">5 Stars</option>
</select>
<p>
<textarea ng-model="reviewCtrl.review.body" placeholder="Digite sua review aqui..." style="width: 75%; height: 25%; resize: none"></textarea>
<p>
<input ng-model="reviewCtrl.review.author" type="email" placeholder="your@email.com"/>
<p>
<button class="btn-toolbar" type="submit" value="Submit">Submit</button>
</form>
</div>

Controller :

 app.controller("ReviewController", function () {
this.review = {};
this.addReview = function (product) {
product.reviews.push(this.review);
this.review = {};
};

this.IsVisible = true;

this.ShowHide = function () {
//If DIV is visible it will be hidden and vice versa.
this.IsVisible = !this.IsVisible;
console.log("foi");
};
});

最佳答案

ng-show ="review Ctrl.Is Visible"> 而不是 ng-show ="review Ctrl.is Visible">

关于javascript - 隐藏和显示表单(Angular JS),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35781483/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com