0

Why does the console.log execute twice even though I am only calling it once. You can see the console.log by inspecting the console on this page. I am using angularjs to retrieve the data that I am trying to console. I couldn't find any online resources pointing this being an issue with angularjs Below is the js but it is also available when viewing source on the page.

JS

var app = angular.module('myApp', []);
app.controller('myController', function ($scope, $http, $filter) {
    $http.get("files/tickets.json")
    .then(function (response) {
        var status = response.status;
        var statusText = response.statusText;
        var headers = response.headers;
        var config = response.config;

        $scope.tickets = response.data;

        $scope.ticketsA = $scope.tickets["ticketsA"];
        $scope.ticketsB = $scope.tickets["ticketsB"];

        console.log($scope.tickets);
        console.log("Testing...");

        ...

    }).catch(function (response) {
        console.log(response);
    })
});
georgeawg
  • 48,608
  • 13
  • 72
  • 95

1 Answers1

0

It is executing twice because the ng-controller is instantiated twice:

<body ng-app="myApp" ng-controller="myController" class="ng-scope">
    <div class="wrapper" style="margin-top: 20px;">
        <div class="container ng-scope" ng-app="myApp" ng-controller="myController">
georgeawg
  • 48,608
  • 13
  • 72
  • 95