Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/389.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript AngularJS-使用带有模板代码的数据目录作为搜索函数_Javascript_Html_Angularjs_Visual Studio 2013_Angularjs Directive - Fatal编程技术网

Javascript AngularJS-使用带有模板代码的数据目录作为搜索函数

Javascript AngularJS-使用带有模板代码的数据目录作为搜索函数,javascript,html,angularjs,visual-studio-2013,angularjs-directive,Javascript,Html,Angularjs,Visual Studio 2013,Angularjs Directive,我再一次在AngularJS中遇到一些代码问题 这一次主要是由于目录,因为它以前没有它也能工作 我认为主要问题与指令.js模板代码中的do_sort()和do_show()函数有关,这些函数实际上从未被调用 尽管需要提及的是,模板代码的链接部分会按需要呈现(请参见printscreen) 有没有聪明的猜测我错过了什么 Index.html 指令.js angular.module('TodoApp.directives',[])。 指令('sorted',函数(){ 返回{ 范围:正确, 是的,

我再一次在AngularJS中遇到一些代码问题

这一次主要是由于目录,因为它以前没有它也能工作

我认为主要问题与
指令.js
模板代码中的
do_sort()
do_show()
函数有关,这些函数实际上从未被调用

尽管需要提及的是,模板代码的链接部分会按需要呈现(请参见printscreen)

有没有聪明的猜测我错过了什么

Index.html 指令.js
angular.module('TodoApp.directives',[])。
指令('sorted',函数(){
返回{
范围:正确,
是的,
模板:“”+
'>' +

“将这两个函数
doSort()
doShow()
重命名为其正确名称

它正在工作

指令.js
angular.module('TodoApp.directives',[])。
指令('sorted',函数(){
返回{
范围:正确,
是的,
模板:“”+
'>' +

'要么回答自己的问题,要么删除它!
<!DOCTYPE html>
<html ng-app="TodoApp">
<head>
    <!-- Core AngularJS -->
    <script src="Scripts/jquery-1.10.2.js"></script>
    <script src="Scripts/angular.js"></script>
    <script src="Scripts/angular-resource.js"></script>
    <script src="Scripts/angular-route.js"></script>
    <!-- Custom AngularJS files -->
    <script src="Scripts/app.js"></script>
    <script src="Scripts/controllers.js"></script>
    <script src="Scripts/services.js"></script>
    <script src="Scripts/directives.js"></script>
    <!-- Bootstrap -->
    <script src="Content/Bootstrap/js/bootstrap.min.js"></script>
    <link href="Content/Bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <link href="Content/Bootstrap/css/bootstrap.icon-large.css" />

    <title>Amazing Todo</title>
</head>
<body>
    <div class="container">
        <div ng-view></div>
    </div>
</body>
</html>
<table class="table table-striped table-condensed table-hover">
    <thead>
        <th sorted="Todo">Todo</th>
        <th sorted="Priority">Priority</th>
        <th sorted="DueDate">Due</th>
    </thead>
    <tbody>
        <tr ng-repeat="item in todos">
            <td>{{item.Todo}}</td>
            <td>{{item.Priority}}</td>
            <td>{{item.DueDate}}</td>
        </tr>
    </tbody>
</table>
angular.module('TodoApp.controllers', []).
    controller('listCtrl', function($scope, $location, todoApiService) {

    $scope.search = function() {
        $scope.todos = todoApiService.getMyTodos().query({ sort: $scope.sort_order, desc: $scope.is_desc });
    };

    $scope.sort = function(col) {
        if ($scope.sort_order === col) {
            $scope.is_desc = !$scope.is_desc;
            $scope.search();
        } else {
            $scope.sort_order = col;
            $scope.is_desc = false;
            $scope.search();
        }
    };

    $scope.sort_order = "Priority";
        $scope.is_desc = false;

        $scope.search();

    });
angular.module('TodoApp.directives', []).
    directive('sorted', function () {
        return {
            scope: true,
            transclude: true,
            template: '<a ng-click="do_sort()" ng-transclude></a>' +
                '<span ng-show="do_show(true)">></span>' +
                '<span ng-show="do_show(false)"><</span>',
            controller: function ($scope, $element, $attrs) {

                $scope.sort_order = $attrs.sorted;

                $scope.doSort = function () {
                    $scope.sort($scope.sort_order);
                };

                $scope.doShow = function (asc) {
                    return asc != $scope.is_desc && col == $scope.sort_order;
                };
            }
        };
    });
angular.module('TodoApp.directives', []).
    directive('sorted', function () {
        return {
            scope: true,
            transclude: true,
            template: '<a ng-click="do_sort()" ng-transclude></a>' +
                '<span ng-show="do_show(true)">></span>' +
                '<span ng-show="do_show(false)"><</span>',
            controller: function ($scope, $element, $attrs) {

                $scope.sort_order = $attrs.sorted;

                $scope.do_sort = function () {
                    $scope.sort($scope.sort_order);
                };

                $scope.do_show = function (asc) {
                    return asc != $scope.is_desc && col == $scope.sort_order;
                };
            }
        };
    });