Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/319.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 在js window.location.href中,通过此命令,按下按钮不移动到所需页面_Javascript_C#_Angularjs - Fatal编程技术网

Javascript 在js window.location.href中,通过此命令,按下按钮不移动到所需页面

Javascript 在js window.location.href中,通过此命令,按下按钮不移动到所需页面,javascript,c#,angularjs,Javascript,C#,Angularjs,我有一个问题,当我点击表中的发送按钮时,它没有带我到请求的页面,我检查了数据库和服务器端的所有方面,我不明白为什么会出现错误400 代码角度 添加链接可以下载代码 代码c#服务器端 [HttpGet] [Route("api/Places/Details/Detail")] public IHttpActionResult Test(int Id) { var service = Services.SqlPool.Plac

我有一个问题,当我点击表中的发送按钮时,它没有带我到请求的页面,我检查了数据库和服务器端的所有方面,我不明白为什么会出现错误400 代码角度
添加链接可以下载代码

代码c#服务器端

 [HttpGet]
        [Route("api/Places/Details/Detail")]
        public IHttpActionResult Test(int Id)
        {
            var service = Services.SqlPool.PlacesService;
            using (var conn = service.StartConnection())
            {
                var result = service.SelectAsList<Models.EventsByDays>(conn, "spGetDetailsAboutPlace", new SqlParameter("@Id", Id));

                service.StopConnection(conn);

                return Ok(result);
            }
        }
        public void Dispose()
        {
            // any operation which aim to free memory is welcomed here :)
        }

    }
[HttpGet]
[路线(“api/地点/细节/细节”)]
公共IHttpActionResult测试(int Id)
{
var service=Services.SqlPool.PlacesService;
使用(var conn=service.StartConnection())
{
var result=service.SelectAsList(conn,“spGetDetailsAboutPlace”,新的SqlParameter(“@Id”,Id));
服务。停止连接(conn);
返回Ok(结果);
}
}
公共空间处置()
{
//此处欢迎任何旨在释放内存的操作:)
}
}
更改您的

 window.location.href = 'Detail.html?Id=' + row.Title;

(别忘了用$http和$scope添加$state)

编辑:

function FrameController($scope, $http, $state) {
var data;
$http.get('/api/places/frames/frame').then(function (response) {


    $scope.rows = response.data.map(function (item) {
        return new MenuEventModel(item);

    });

    data = angular.copy($scope.rows);

    $scope.loaded = true;
    console.log($scope.rows);


    $scope.send = function (row) {
        console.log(row);

        var linkStart = 'Detail.html?Id=' + row.Title;
$state.go(linkStart);

    };
});
}

或者使用$window而不是$state。

将html更改为:

<head>
    <script>
        (function (app) {
            app.controller('FrameController', FrameController)
        })(angular.module('TestApp', ['ngAnimate', 'ngAria', 'ngMaterial']));
    </script>
</head>
<body ng-controller="FrameController">
    <div ng-cloak>
        <md-content>
            <div layout="row" layout-wrap>
                <div flex="50">
                    <div class="mdl-grid">
                        <md-card>
                            <md-card-title>

                                <md-card-title-text>
                                    <span class="md-headline"> </span>
                                </md-card-title-text>
                                <md-card-title-media>
                                    <md-progress-linear md-mode="indeterminate"></md-progress-linear>
                                    <div class="md-media-lg card-media"></div>
                                </md-card-title-media>
                            </md-card-title>
                            <md-card-content>
                                <md-datepicker ng-model="myDate" md-placeholder="Enter date"></md-datepicker>
                                <md-select ng-model="searchText" placeholder="choose place" class="md-no-underline">
                                    <md-option value="Club">Club</md-option>
                                    <md-option value="Bar">Bar</md-option>
                                    <md-option value="Dance-Bar">Dance-Bar</md-option>
                                    <md-option value="Resturant">Resturant</md-option>
                                    <md-option value=" coffe-shops">Coffe-shops</md-option>
                                </md-select>
                                <input type="text" placeholder="enter the place you want" ng-model="searchText.Title">
                            </md-card-content>
                            <md-card-actions layout="row" layout-align="end center">

                            </md-card-actions>
                        </md-card>
                    </div>
                </div>

                <table class="mdl-data-table mdl-js-data-table mdl-shadow--2dp">
                    <thead>
                        <tr>
                            <th class="mdl-data-table__cell--non-numeric">Title</th>
                            <th>Description</th>
                            <th>Phone</th>
                            <th>City</th>
                            <th>Street</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr ng-repeat="row in rows | filter:searchText">

                            <td class="mdl-data-table__cell--non-numeric">{{row.Title}}</td>
                            <td>{{row.Description}}</td>
                            <td>{{row.Phone}}</td>
                            <td>{{row.City}}</td>
                            <td>{{row.Street}}</td>
                            <td><button ng-click="send($event, row)">Send</button></td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </md-content>
    </div>
</body>

(我假设你的“'Detail.html?Id='+row.Title;”提供了一个有效的路由)我试图更改,但没有帮助,添加了代码服务器side我添加了下载代码的链接是的,这个错误HTTP错误404.0-如果你无法尝试将绝对URL重定向,则找不到。这个链接是什么?我发现了你的问题,但问题很多。请允许我检查所有这些。它有效,您有
window.location.href='Details.html?Id='+row.Title
在您的
frames.js
中,您必须将其更改为
window.location.href='Detail.html?Id='+row.Title
var linkStart = 'Detail.html?Id=' + row.Title;
$state.go(linkStart);
function FrameController($scope, $http, $state) {
var data;
$http.get('/api/places/frames/frame').then(function (response) {


    $scope.rows = response.data.map(function (item) {
        return new MenuEventModel(item);

    });

    data = angular.copy($scope.rows);

    $scope.loaded = true;
    console.log($scope.rows);


    $scope.send = function (row) {
        console.log(row);

        var linkStart = 'Detail.html?Id=' + row.Title;
$state.go(linkStart);

    };
});
<head>
    <script>
        (function (app) {
            app.controller('FrameController', FrameController)
        })(angular.module('TestApp', ['ngAnimate', 'ngAria', 'ngMaterial']));
    </script>
</head>
<body ng-controller="FrameController">
    <div ng-cloak>
        <md-content>
            <div layout="row" layout-wrap>
                <div flex="50">
                    <div class="mdl-grid">
                        <md-card>
                            <md-card-title>

                                <md-card-title-text>
                                    <span class="md-headline"> </span>
                                </md-card-title-text>
                                <md-card-title-media>
                                    <md-progress-linear md-mode="indeterminate"></md-progress-linear>
                                    <div class="md-media-lg card-media"></div>
                                </md-card-title-media>
                            </md-card-title>
                            <md-card-content>
                                <md-datepicker ng-model="myDate" md-placeholder="Enter date"></md-datepicker>
                                <md-select ng-model="searchText" placeholder="choose place" class="md-no-underline">
                                    <md-option value="Club">Club</md-option>
                                    <md-option value="Bar">Bar</md-option>
                                    <md-option value="Dance-Bar">Dance-Bar</md-option>
                                    <md-option value="Resturant">Resturant</md-option>
                                    <md-option value=" coffe-shops">Coffe-shops</md-option>
                                </md-select>
                                <input type="text" placeholder="enter the place you want" ng-model="searchText.Title">
                            </md-card-content>
                            <md-card-actions layout="row" layout-align="end center">

                            </md-card-actions>
                        </md-card>
                    </div>
                </div>

                <table class="mdl-data-table mdl-js-data-table mdl-shadow--2dp">
                    <thead>
                        <tr>
                            <th class="mdl-data-table__cell--non-numeric">Title</th>
                            <th>Description</th>
                            <th>Phone</th>
                            <th>City</th>
                            <th>Street</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr ng-repeat="row in rows | filter:searchText">

                            <td class="mdl-data-table__cell--non-numeric">{{row.Title}}</td>
                            <td>{{row.Description}}</td>
                            <td>{{row.Phone}}</td>
                            <td>{{row.City}}</td>
                            <td>{{row.Street}}</td>
                            <td><button ng-click="send($event, row)">Send</button></td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </md-content>
    </div>
</body>
function FrameController($scope, $http, $window) {
        var data;
        $http.get('/api/places/frames/frame').then(function (response) {
            $scope.rows = response.data.map(function (item) {
                return new MenuEventModel(item);

            });
            data = angular.copy($scope.rows);
            $scope.loaded = true;
            console.log($scope.rows);

            $scope.send = function (e, row) {
                e.preventDefault();
                console.log(row);
                $window.location.href = 'http://...' + 'Detail.html?Id=' + row.Title;
            };
        });
    }