如何传递给@Model角NG-INIT [英] How can I pass @Model to Angular ng-init

查看:114
本文介绍了如何传递给@Model角NG-INIT的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是不是有可能@Model传递给 NG-INIT 在ASP.NET MVC 4看法?当我这样做数据-NG-的init =的init(@Model)它是在未定义的init()功能。

Isn't it possible to pass @Model to ng-init in ASP.NET MVC 4 view? When I do it like data-ng-init=init(@Model) it is undefined in the init() function.

$scope.init = fuynction(model){
    console.log(model); // prints undefined
}

这是我新的AngularJs的方式。任何帮助AP preciated提前。

By the way I'm new to AngularJs. Any help is appreciated in advance.

推荐答案

你序列化模型转换成JSON字符串,用Newtonsoft.Json装配或相似,通过系列化结果数据-NG-INT。

Serialize you model into json string, using Newtonsoft.Json assembly or similar and pass the serialization result to data-ng-init.

这篇关于如何传递给@Model角NG-INIT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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