1

我正在使用 Type Script 和 Angular js 我已经实现了一个控制器,它命名为快速搜索,并且我正在尝试执行搜索操作。我正在从我的 aspx 的文本框中获取搜索词,而不是在 ng click它将进入我的控制器,然后将数据放入 web api 方法,然后将结果返回到网格。但是由于未捕获的ReferenceError,我遇到了问题:未定义角度我在下面编写了我的控制器代码:-

/// <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]);

}
4

1 回答 1

0

我通过更改我的 java 脚本引用的顺序解决了这个问题。作为 :-

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"
于 2015-06-02T09:55:40.050 回答