Javascript 离子1-按下按钮后隐藏按钮
在我的ionic mobile应用程序上按下like按钮后,我试图隐藏它。但它不是只隐藏那个按钮,而是隐藏所有类似的按钮。如何单独隐藏一个按钮,而不是隐藏所有按钮?这是我试图实现的代码 activities.html:Javascript 离子1-按下按钮后隐藏按钮,javascript,angularjs,ionic-framework,Javascript,Angularjs,Ionic Framework,在我的ionic mobile应用程序上按下like按钮后,我试图隐藏它。但它不是只隐藏那个按钮,而是隐藏所有类似的按钮。如何单独隐藏一个按钮,而不是隐藏所有按钮?这是我试图实现的代码 activities.html: <div class="item item-text-wrap" ng-repeat="activities1 in activities" id = $index> <div> Seen on: {{activities1.view
<div class="item item-text-wrap" ng-repeat="activities1 in activities" id = $index>
<div>
Seen on: {{activities1.viewedDate}}
<br>
{{activities1.title}}
</div>
<iframe width="420" height="315" src="{{activities1.url}}"></iframe>
<div class="item item-input-inset">
<button class="button button-full button-balanced" ng-click="invertLike(activities1);" ng-hide="ShowDiv">
Like!
</button>
<button class="button button-full button-assertive" ng-click="Dislike(activities1);" ng-hide="ShowDiv2">
Unlike!
</button>
</div>
</div>
非常感谢您的帮助。由于按钮共享了模型数据,因此可能会出现此问题。您可以添加子控制器并将按钮环绕在其周围。那会解决你的问题。请参阅上的完整示例代码
显示您的控制器编辑问题。
database.ref('/activitiesInvite/' ).orderByChild("name").equalTo(username).on('value', function(activitys){
$scope.activities = activitys.val();
$scope.invertLike = function(index) {
var id = index.id;
firebase.database().ref('activitiesInvite').orderByChild("id").equalTo(id).on("value", function(snapshot)
{
{
var key;
$scope.check = snapshot.val().interest;
console.log($scope.check);
snapshot.forEach(function (childSnapshot) {
key = childSnapshot.key;
})
if(key)
{
firebase.database().ref('/activitiesInvite/' + key).on("value", function(test)
{
firebase.database().ref().child('/activitiesInvite/' + key)
.update({ interest: "user has liked", });
if($scope.check != "")
{
$scope.ShowDiv = true;
}
})
}
}
//Main Module, Main Controller
angular.module('myApp', []).controller('MainCtrl', function($scope) {
$scope.activities = [{
title: 'Jani',
url: 'www.google.com',
viewedDate: new Date().toLocaleDateString("en-US")
}];
$scope.ShowDiv = false;
$scope.ShowDiv2 = false;
})
//Child Controller (Isolate the Scope of the variables from Parent Controller)
.controller('ChildCtrl', function($scope) {
$scope.invertLike = function(activities1) {
//Scope Inherited From Parent
$scope.ShowDiv = true;
};
$scope.Dislike = function(activities1) {
//Scope Inherited From Parent
$scope.ShowDiv2 = true;
};
});