In order to make your code work, you need to run $scope.$digest() after you assign $scope.carname = "Audi";
Like this:
app.controller('myCtrl', function($scope) {
$scope.carname = "Volvo";
$('#sample').click(function(e){
$scope.carname = "Audi";
$scope.$digest();
});
});
Here's a w3schools link to the program: Link
As mentioned in the comments below, you can also use $scope.$apply() like the following:
app.controller('myCtrl', function($scope) {
$scope.carname = "Volvo";
$('#sample').click(function(e){
$scope.$apply( function() {
$scope.carname = "Audi";
});
});
});
Here's a w3schools link to the program: Link
You can read more about the use cases for $scope.$digest() and $scope.$apply() in the following links:
Note: As mentioned in many other comments & some answers, Angular does provide a built-in method to listen for a click event, called ng-click. Here is the documentation for it: AngularJS: ngClick
ng-clickhandler