I'm facing an issue with two buttons on my page.
<div class="btn-group" ng-init="showData = 1">
<button ng-model="showData" type="button" ng-class='{"btn btn-primary": showData == 1, "btn btn-white": showData != 1}' ng-click="showData = 1">Headline</button>
<button ng-click="eventDescription()" ng-model="showData" type="button" ng-class='{"btn btn-primary":showData == 2, "btn btn-white": showData != 2}' ng-click="showData = 2">Summary</button>
</div>
In the controller, I have a function that triggers a web service call. The function outputs a message to the console for verification purposes. Here is a simplified version of the function:
$scope.eventDescription = function () {
// Some code here
console.log("Service OK")
}
The specific code within the function is omitted due to its irrelevance
Despite using ng-click in my AngularJS setup, clicking the button does not switch to the intended view. As a novice in Angular development, I am unsure of what might be causing this issue.
Additionally, depending on which button is selected, I display different directives (which render HTML content) like so:
<head-line-view ng-show="showData == 1"></head-line-view>
<summary-view ng-show="showData == 2"></summary-view>