I\'m new to Angular, and I am trying to do something really basic. Here is a part of a view (all angular files are added elsewhere) :
The value will automatically be added to the $scope
, but you have to type something into the input
element.
That said, you need to trigger something to get this value. For example, where you have your comment // get the scope value here
-- this is triggered as soon as the controller is initialized and never called again; so, it's going to log undefined at that time. However, if you set it to a button click, or something, you will see it's available:
And your controller:
module.controller('ctrl',['$scope', function ($scope) {
$scope.logId = function() {
console.log($scope.id);
}
}]);
Now type something into the input and click the button.