相关疑难解决方法(0)

在AngularJS中有条件地应用属性的最佳方法是什么?

我需要能够根据范围内的布尔变量向元素添加"contenteditable".

使用示例:

<h1 attrs="{'contenteditable=\"true\"': editMode}">{{content.title}}</h1>
Run Code Online (Sandbox Code Playgroud)

如果$scope.editMode设置为,则会导致将contenteditable = true添加到元素中true.有没有一些简单的方法来实现这样的ng-class属性行为?我正在考虑写一个指令并分享,如果没有.

编辑: 我可以看到我提出的attrs指令和ng-bind-attrs之间似乎有一些相似之处,但它在1.0.0.rc3中删除了,为什么会这样呢?

angularjs angularjs-directive

288
推荐指数
9
解决办法
27万
查看次数

标签 统计

angularjs ×1

angularjs-directive ×1