<div class="popover-content" ng-click="updateHeader('alice')">
Upon clicking this specific div, a function is triggered which initiates a get request.
var application = angular.module('myApp', []);
application.controller('myContoller', function($scope, $http) {
$scope.username = "";
$scope.updateHeader = function(username) {
var url = "api?user="+ username;
$http.get(url)
.then(function(response) {
$scope.username = response.data.plugUser;
console.log($scope.username);
$scope.scrollableChatItems = response.data.msg;
});
};
};
Although the console.log statement functions correctly and displays the username in the console, it fails to update the username itself. Why might the username not be updating?
<div class="container" ng-controller="myController">
<h3 class="content-box-header">
{{username}}
</h3>