在标签html中使用角度变量

时间:2017-02-16 12:11:28

标签: c# angularjs asp.net-mvc html5

这是我的controller.js代码:

$scope.animatt = 900;

这是我的HTML代码:

<div id="properties" data-{{animatt}}="left:100%;top:10%;">
                <h2>all numeric properties</h2>
</div>

我想将'data-900 ='设置为'data - {{animatt}}',但此代码不起作用

1 个答案:

答案 0 :(得分:0)

在您的控制器中,添加以下代码

var el =angular.element('#properties');
el.attr('data-' + $scope.animatt, 'left:100%;top:10%;');