I'd like to be able to access a controller variable inside a function of this controller.
Why is the following code throwing an error into the console instead of showing the input value ?
JS:
var app = angular.module("app", []); app.controller("TestCtrl", function($scope) { $scope.string = ""; $scope.click = function() { // I've also tried with $scope in parameter console.debug(string); // and $scope.string here, same issue } }); HTML :
<div ng-app="app" ng-controller="TestCtrl"> <input type="text" ng-model="string"></input> <button ng-click="click()">Click me !</button> </div>