吴角式与属性更改 [英] Angular ng-style not changing with property

查看:120
本文介绍了吴角式与属性更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有关我的生活我似乎无法找出原因样式属性不会得到更新。在我更大的应用程序似乎很好地工作。

For the life of me I cant seem to figure out why the style property is not getting updated. In my larger application it seems to work fine.

http://jsfiddle.net/ganarajpr/C2hRa/4/

下面是一个小提琴这说明我目前所面临的问题。你会发现,在宽度和高度的DIV当您更改输入得到更新。但是这种风格本身似乎没有被更新。谁能告诉我什么,我做错了什么?

Here is a fiddle which shows the issue I am currently facing. You will notice that the width and height are getting updated in the div when you change the input. But the style itself doesnt seem to be updating. Anyone can tell me what I am doing wrong here?

我已经尝试了所有的以下情形

I have tried all the following scenarios


  1. 使用$ $范围适用。 - 抛出一个错误,说明已经$申请正在进行中。

  2. $ rootScope $应用 - 同上

  3. ,其中在其他控制器$观看的服务设置另一个变量。 - 无变化看到

这将是非常酷的,如果有人可以给我一个答案。也将是,如果你能告诉我到底为什么它没有得到更新真的很开心。

It would be really cool if someone can get me an answer to this. Also would be really happy if you can tell me why exactly it is not getting updated.

推荐答案

您已经分配的宽度和高度值的myprop式现场的一次性基础。所以,当您更改宽度或高度myprop没有发生变化。

You had assigned the width and height values to the myprop style field on a one-off basis. So when you changed the width or height the myprop was not changing.

在myprop值更改为一个计算它的价值,而不是一个函数...

Change the myprop value to a function that computes its value instead...

http://jsfiddle.net/DyHHJ/

这篇关于吴角式与属性更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆