179
rated 0 times
[
180]
[
1]
/ answers: 1 / hits: 18486
/ 11 Years ago, fri, august 9, 2013, 12:00:00
I'm learning Angular.js and I set <title>{{title}}</title>
and I try to change that using select element
<select ng-model=user.title>
<option value=Lorem>Lorem</option>
<option value=Ipsum>Ipsum</option>
<option value=Dolor>Dolor</option>
</select>
I try ng-change
and ng-select
with set()
function ctrl($scope) {
$scope.title = 'hello'; // this set the title
$scope.set = function() {
$scope.title = $scope.user.title; // this not
};
}
THe function don't work, but it work when I just set it without a function.
I also try to create change directive:
app.directive('change', function() {
console.log('change');
return {
link: function(scope, element, attrs) {
console.log(arguments);
element[0].onChange = function() {
scope[attrs[0]]();
};
}
};
});
but this too don't work. Console.log don't execute at all.
More From » angularjs