Search code examples
angularjsangularjs-scopetypescripttypescript1.4typescript1.5

Uncaught ReferenceError: angular is not defined using type script


I am working with Type Script and Angular js I have implemented a Controller which names as quick search and from that i am trying to perform search opeartions .I which i am getting the search term in a text box from my aspx and than on ng click it will goes to my controller and than it will Put data into web api method and than return resuts in to grid. But i am facing problem because of Uncaught ReferenceError: angular is not defined i have written my controller code below:-

/// <reference path="../interface/interface.ts" />
/// <reference path="../../scripts/typings/jquery/jquery.d.ts" />
/// <reference path="../../scripts/typings/angularjs/angular.d.ts" />
module CustomerSearch.CustomerCtrl {
    export class CustomerCtrl {
        static $inject = ['$scope', '$http', '$templateCache'];

        constructor(protected $scope: ICustomerScope,
            protected $http: ng.IHttpService,
            protected $templateCache: ng.ITemplateCacheService) {
            $scope.search = this.search;
            console.log(angular.element($scope).scope());
        }
        public search = (search: any) => {
            debugger;
           var Search = {
                ActId: search.txtAct,
                checkActiveOnly: search.checkActiveOnly,
                checkParentsOnly: search.checkParentsOnly,
                listCustomerType: search.listCustomerType
            };

            this.$scope.customer = [];
            this.$scope.ticket = [];
            this.$scope.services = [];


            this.$http.put('<%=ResolveUrl("/API/Search/PutDoSearch")%>', Search).
                success((data, status, headers, config) => {
                debugger;
                this.$scope.cust_File = data[0].customers;
                this.$scope.ticket_file = data[0].tickets;
                this.$scope.service_file = data[0].services;
            }).
                error((data, status) => {
                console.log("Request Failed");
                });

        }
    }
    var customerapp = angular.module("CustomerSearch", []);
    customerapp.controller('CustomerCtrl',["$scope", CustomerCtrl]);

}

Solution

  • I have solved this Question by changing the sequence of my java script references. as :-

    1.jquery-latest.js
    2.app.module.js" 
    3.Controller.js" 
    4.Interface.js" 
    5.angular.js" 
    6.angular.min.js" 
    7.app.routes.js"