描述:
<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”的问题解答,希望对有需要的网友有所帮助。
没明白你的具体需求,但是我觉得这样做比较好,使用模板声明的方式,而不是在js里创建组件。注意下面的<ng-content>
import {Component} from '@angular/core'
@Component({
selector: 'parent',
template: `
<div>
<h1>parent</h1>
<ng-content></ng-content>
</div>
`
})
export class ParentComponent {}
@Component({
selector: 'child',
template: `<h1>child</h1>`
})
export class ChildComponent {}
@Component({
selector: 'demo',
template: `<parent><child></child></
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)