angularjs - MVC Dropdownlist with Angular Selecting default -
i new both mvc , angularjs. having layout page , in layout page partial view having dropdown , render body. on selection change of value content change of view in render body. using mvc @html.dropdownlist
since data list in session.
now want change view data on change of dropdown values doing angular.
below code of partial view.
@html.dropdownlist("loanaccounttypemodels", new selectlist(((mymodel.userdetailsmodel)session["ud"]).loanaccounttypemodels), new { style = "height: 30px; width:250px;", ng_change = "updatechildviews()", ng_init="loanaccounttypemodel = options[0]" , ng_model = "loanaccounttypemodel" })
my _layout page is
<!doctype html> <html lang="en"> <head> <script src="~/scripts/angular.js"></script> @styles.render("~/content/css") @styles.render("~/css/_layout") @scripts.render("~/js/jquery.js") @scripts.render("~/bundles/jquery") @scripts.render("~/bundles/bootstrap") @scripts.render("~/js/_layout.js") </head> <body ng-app="clientportalglobalngapp"> <div id="wrapper" ng-controller="clientportalglobalngcontroller"> <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation"> <!-- brand , toggle grouped better mobile display --> <div class="navbar-header"> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse"> <span class="sr-only">toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <div> <a class="navbar-brand" href="index.html"><img src="../assets/img/axis_bank_logo.png" style="width:65%;"> </a></div> </div> @html.partial("_headerpartial") </nav> <h3>{{homepagemodel.totalsanctionedamt}}</h3> @renderbody(); </div> </body>
and _layout.js page is
function clientportalglobalngcontroller($scope, $http) { $scope.updatechildviews = function (ddlaccounttype) { if ($scope.currentselected == "home") { $scope.homepagemodel = { totalsanctionedamt: "10", customerdetail: { primaryholdername: "x" } }; } } } var app = angular.module("clientportalglobalngapp", []); app.controller("clientportalglobalngcontroller", clientportalglobalngcontroller);
i have tried $scope.form = { type: $scope.typeoptions[0].value };
in controller selecting default giving typeerror: cannot read property '0' of undefined
, angular code not working , rendering {{homepagemodel.totalsanctionedamt}}
in final html instead of blank value.
please suggest. have been wandering on stack overflow 2 days. no help. please suggest me best way it.
Comments
Post a Comment