我是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將被刪除,該按鈕也將被刪除 –