Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
From MVC back to controller.js
Message
 
 
To
All
General information
Forum:
Javascript
Category:
Other
Title:
From MVC back to controller.js
Miscellaneous
Thread ID:
01615833
Message ID:
01615833
Views:
34
UPDATE. Found this http://stackoverflow.com/questions/18446359/angularjs-does-not-send-hidden-field-value and trying ng-value right now.

UPDATE 2. Worked out solution using ng-init.

Hi everybody,

I'm trying to help my colleague to pass the property from MVC back to controller.js.

We saved the property in the ViewBag (I don't really like this approach, but anyway).

Here is what he had and it displays correctly:
<div class="pull-left col-lg-11">@ViewBag.homeArea @Labels.reports</div>
So, we need to somehow pass that @ViewBag.homeArea back to our controller.

This is my not working attempt:
<input type="hidden" id="homeArea" ng-model="reportsParameters.homeArea" name="homeArea" value="{{'@ViewBag.homeArea'}}"/>
And in the controller we defined
$scope.reportsParameters = { homeArea: '', groupId: 0 };
The problem is, that somehow that hidden field is not updating the model back. The value is correct when we inspect the element, but the reportsParameters.homeArea remains the same empty string.

Do you see what is wrong here and what is the best way to pass that ViewBag.homeArea property back to the controller's scope?

Thanks a lot in advance.
If it's not broken, fix it until it is.


My Blog
Reply
Map
View

Click here to load this message in the networking platform