Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用HTML属性更新角度变量_Html_Angularjs_Data Binding_Dynamic Variables - Fatal编程技术网

如何使用HTML属性更新角度变量

如何使用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(不是原始组件/指令)

我熟悉以相反方向共享这些数据,即使用角度变量更新属性

e、 g

//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>