angularjs怎样实现Jq的addclassremoveclass

angularjs怎样实现Jq的addclassremoveclass,第1张

问题: angularjs怎样实现Jq的addclass\removeclass

描述:

<a >编辑信息</a>

.border-none{

border:none

}

如何用angular.js实现点击a标签,添加类border-none,再次点击,删除类border-none

解决方案1:

给你个例子吧

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml" ng-app="app">

<head>

<title>show-hide</title>

<script src="JS/angular.min.js"></script>

<script>

var app = angular.module('app', [])

app.controller('showHideController', function ($scope) {

$scope.isShow = true

$scope.showorhide = function () {

$scope.isShow = !$scope.isShow

}

})

</script>

<style>

.div {

border: 1px solid #0094ff

background-color: rebeccapurple

}

</style>

</head>

<body>

<div ng-c>this is a div which is show</div>

<!--<div ng-show="!isShow">this is a div which is hide</div>-->

<button ng-click="showorhide()">按钮</button>

</div>

</body>

</html>

我网上复制的。 解决方案2:

ng-click 事件啊···然后在js里面用jquery *** 作 可能我这个方法有点low

解决方案3:

NG就用NG的思维啊,数据绑定才是正确的做法

用ng-class

以上介绍了“ angularjs怎样实现Jq的addclass\removeclass”的问题解答,希望对有需要的网友有所帮助。

angularjs中ng-class和class到底有什么区别,怎么用ng-class呢 ng-class是根据 key: value来设置class你看angularjs进阶的课程.看对你有帮助不. function ctr($scope){ $scope.test


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/bake/11601504.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-17
下一篇 2023-05-17

发表评论

登录后才能评论

评论列表(0条)

保存