0

I have this MVC application mix with angular. On Menu click we access this ClientController in server side Mvc

Partial 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 

Then i have this in my view ClientPartial.vbhtml

<div ng-controller="studentController">
{{studentId}}
</div>

My angular controller is

 var mainApp = angular.module("mainApp", []); mainApp.controller('studentController', function ($scope) {
$scope.studentId = "From MVC";});


enter code here

The problem is how can i get the StudentId in my angular controller?

1 Answer 1

1

You can use ng-init

<div ng-controller="studentController" ng-init="[email protected]">
{{studentId}}
</div>
Sign up to request clarification or add additional context in comments.

2 Comments

The problem is that i need this studentId in the controller to load a dropdownControl code function getcourse() { return datacontext.getcourse(this.studentId).then(function (data) { return vm.courselist = data; }); } So i need to have this variable available to load the dropdown
Using the suggested approach is a good fit, you can then use a watch to load de dropdown by observing changes on the studentId controller variable. ex: $scope.$watch('studentId',function(newValue,oldValue) { if(newValue) { getCourse(newValue); } });

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.