我将此MVC应用程序与角度混合。在菜单上单击,我们访问服务器端Mvc
中的此ClientControllerPartial Public Class ClientController
Inherits System.Web.Mvc.Controller
Function ClientPartial(ByVal id As Integer) As System.Web.Mvc.ActionResult
Dim student As ManagedForm(Of mmClientPartial) = utils.GetForm(Of mmClientPartial)(id)
Return PartialView("ClientPartial", student)
End Function
End Class
然后我在我的视图ClientPartial.vbhtml
中有这个<div ng-controller="studentController">
{{studentId}}
</div>
我的角度控制器是
var mainApp = angular.module("mainApp", []); mainApp.controller('studentController', function ($scope) {
$scope.studentId = "From MVC";});
enter code here
问题是如何在角度控制器中获得StudentId
?
答案 0 :(得分:1)
您可以使用ng-init
<div ng-controller="studentController" ng-init="studentId=@Model.Id">
{{studentId}}
</div>