Topic: ng binding doesn't work
<select class="mdb-select" id="user-profile" data-ng-model="user.profile">
<option value="" disabled selected>Choose your option</option>
<option value="Self">Self</option>
<option value="Son">Son</option>
<option value="Daughter">Daughter</option>
<option value="Brother">Brother</option>
<option value="Sister">Sister</option>
<option value="Friend">Friend</option>
<option value="Relative">Relative</option>
</select>
Ideally in controller like
$scope.user.profile = $('#user-profile').val(); dineshbhavsar answered 8 years ago
dineshbhavsar answered 8 years ago
Bartłomiej Malanowski staff pro premium answered 8 years ago
dineshbhavsar answered 8 years ago
Bartłomiej Malanowski staff pro premium answered 8 years ago
dineshbhavsar answered 8 years ago
Bartłomiej Malanowski staff pro premium answered 8 years ago
<body ng-app="myApp" ng-controller="RegistrationController">
<select ng-model="user.profileCreatedFor" ng-options="key as key.name for key in masterData.profileCreatedFor track by key.value" class="mdb-select">
<option value="" disabled selected>Choose your option</option>
</select>
<button class="btn btn-primary" ng-click="register()">Submit</button>
<!-- SCRIPTS -->
<!-- Angular -->
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js"></script>
<!-- Angular UI Router -->
<script src="https://unpkg.com/angular-ui-router/release/angular-ui-router.min.js"></script>
<!-- JQuery -->
<script type="text/javascript" src="js/jquery-2.2.3.min.js"></script>
<!-- Bootstrap tooltips -->
<script type="text/javascript" src="js/tether.min.js"></script>
<!-- Bootstrap core JavaScript -->
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<!-- MDB core JavaScript -->
<script type="text/javascript" src="js/mdb.js"></script>
<!-- App -->
<script type="text/javascript">
var app = angular.module('myApp', []);
app.controller('RegistrationController', function($scope) {
$scope.masterData = {}
$scope.masterData.profileCreatedFor = [
{ value: "Self", name: "Self" },
{ value: "Son", name: "Son" },
{ value: "Daughter", name: "Daughter" },
{ value: "Brother", name: "Brother" },
{ value: "Sister", name: "Sister" },
{ value: "Friend", name: "Friend" },
{ value: "Relative", name: "Relative" }
];
});
$(document).ready(function () {
$('.mdb-select').material_select();
});
</script>
</body>
umair answered 8 years ago
Bartłomiej Malanowski staff pro premium answered 8 years ago
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
- User: Free
- Premium support: No
- Technology: MDB Angular
- MDB Version: -
- Device: -
- Browser: -
- OS: -
- Provided sample code: No
- Provided link: No