加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

angularjs – Angular ng-init:’通过服务器端脚本注入数据’

发布时间:2020-12-17 17:15:31 所属栏目:安全 来源:网络整理
导读:来自关于ng-init的Angular文档: This directive can be abused to add unnecessary amounts of logic into your templates. There are only a few appropriate uses of ngInit,such as for aliasing special properties of ngRepeat,as seen in the demo be
来自关于ng-init的Angular文档:

This directive can be abused to add unnecessary amounts of logic into
your templates. There are only a few appropriate uses of ngInit,such
as for aliasing special properties of ngRepeat,as seen in the demo
below; and for injecting data via server side scripting.

任何人都可以解释第二个用例:

…and for injecting data via server side scripting.

具体来说,使用此指令将值从Rails / PHP视图传递给Angular控制器是否合适?

其他方法(使用$location)似乎不必要地复杂化.

解决方法

绝对.如果您的PHP或Rails应用程序生成模板,并且方便(且安全)将数据从该应用程序作为ng-init属性值传递给Angular应用程序,那么这是一个有效的用例.

如果数据是复杂对象和/或可能更改(或由客户端应用程序更改),则生成$http请求更有用.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读