我是AngularJS中的一名新成员。我想做一些非常类似于jquery的语法去除父div的东西。喜欢的东西:
$(this).parent().remove()
我的整个代码是目前:
<!DOCTYPE html>
<html>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
<body>
<div ng-app="myApp" ng-controller="myCtrl">
First Name: <input type="text" ng-model="firstName"><br>
Last Name: <input type="text" ng-model="lastName"><br>
<br>
Full Name: {{firstName + " " + lastName}}
<div>
<button ng-click="Sample()">DEAN</button>
</div>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.firstName = "John";
$scope.lastName = "Doe";
$scope.Sample = function(){
$(this).parent().remove()
};
});
</script>
</body>
</html>
要隐藏在点击该按钮外部? –
你想要删除什么? –
我想要这个div元素作为父按钮来移除按钮。由于该div将被删除,该按钮也将被删除 –