So i am having an issue with adding a variable to the $scope after an event. Here is the HTML for the select box. Basically when it is changed i need the scope to change.
Index.html
<select ng-controller="ClientCtrl" ng-model="name"
ng-options="v.name for (k, v) in client" ng-change="selectChange(name)">
</select>
<h2>{{cName}}</h2>
<p>Age: {{cAge}}</p>
<p>Notes: {{cNotes}}</p>
Controller.js
$scope.selectChange = function(name){
$scope.cName = name.name;
$scope.cAge = name.age;
$scope.cNotes = name.notes;
};
I have tried a few things to get those variable set. Obviously this one above, then this one:
$scope.selectChange = function(name){
$scope.cName = name.name;
$scope.cAge = name.age;
$scope.cNotes = name.notes;
$scope.$apply();
};
I still don't quite understand apply but i thought i'd give it a try. Any help would be awesome, just need a pointer to wrap my head around why this wouldnt work.
I can get the variables to post to the console.log(cName); but it won't show up when i have the {{cName}}