如何使用HTML属性更新角度变量
我熟悉以相反方向共享这些数据,即使用角度变量更新属性 e、 g如何使用HTML属性更新角度变量,html,angularjs,data-binding,dynamic-variables,Html,Angularjs,Data Binding,Dynamic Variables,我熟悉以相反方向共享这些数据,即使用角度变量更新属性 e、 g //js $scope.itemVisible=false; 我还了解通过带有指令/组件的属性更新html的能力 e、 g //js app.module('example',[]).component('someComponent'{ 绑定:{ someAttribute:'=' }, 控制器:函数(){ this.someValue='Schwifty' } } 但我想知道是否有一种方法可以在纯html(不是原始组件/指令)
//js
$scope.itemVisible=false;
我还了解通过带有指令/组件的属性更新html的能力
e、 g
//js
app.module('example',[]).component('someComponent'{
绑定:{
someAttribute:'='
},
控制器:函数(){
this.someValue='Schwifty'
}
}
但我想知道是否有一种方法可以在纯html(不是原始组件/指令)上执行后一种操作,就像这样
e、 g
{{id}
我知道这显然不是正确的语法,但这是我的一厢情愿,并给出了一个我想做的简单示例
谢谢!So
{id}
应该更新为div.id='Snuffles'
?你想实现什么?我希望{id}与div中的id具有相同的值,是的。因此它将呈现为“Snuffles”
//js
$scope.itemVisible = false;
<--html-->
<div style="visibility:{{itemVisible}}">
//js
app.module('example', []).component('someComponent', {
bindings: {
someAttribute: '='
},
controller: function(){
this.someValue = 'Schwifty'
}
}
<--html-->
<some-component some-attribute="someValue"></some-component>
<--{{id}} being the value given to the id attribute in the container div -->
<div id="Snuffles"><span>{{id}}</span></div>