从玉传递变量NG-INIT不工作 [英] Passing variable from jade to ng-init not working

查看:254
本文介绍了从玉传递变量NG-INIT不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从玉传递一个对象到NG-初始化的角

本:不工作:

  NG-的init ='表=!{JSON.stringify(表)}

本:扩展,但

  NG-的init ='表=#{JSON.stringify(表)}

输出转义,充满了&放大器; QUOT; 取值

  NG-的init =表= {&放大器; QUOT; 12安培; QUOT;:{&放大器; QUOT; ID&安培; QUOT;:....

和视图不会更新任何一种情况下。 本文意味着第一一个人应该工作,但就像我说的,它甚至不扩大,

  NG-的init ='表=!{JSON.stringify(表)}

在源$ C ​​$ C显示在HTML源代码完全相同

  NG-的init ='表=!{JSON.stringify(表)}


解决方案

其实,#{...} 办法似乎很好地工作。结果
这可能是路的console.log 打印属性的值,能够干扰你。

  NG-的init =表=#{JSON.stringify(表)}

看看这个 短演示

I'm trying to pass an object from jade to ng-init in angular

This: doesn't work:

ng-init='tables=!{JSON.stringify(tables)}'

This: expands but,

ng-init='tables=#{JSON.stringify(tables)}'

the output is unescaped and filled with "s

ng-init="tables={"12":{"id":....

and the view isn't updated in either of the cases. This article implies that first one should work, but like I said, it doesn't even expand,

ng-init='tables=!{JSON.stringify(tables)}'

in source code shows up exactly the same in the HTML source

ng-init='tables=!{JSON.stringify(tables)}'

解决方案

Actually, the #{...} approach seems to work fine.
It is probably the way console.log prints attributes' values that confused you.

ng-init="tables=#{JSON.stringify(tables)}"

Take a look at this short demo.

这篇关于从玉传递变量NG-INIT不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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