Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/21.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
Angularjs 后退箭头和角度布线-按后退两次_Angularjs_Angularjs Routing - Fatal编程技术网

Angularjs 后退箭头和角度布线-按后退两次

Angularjs 后退箭头和角度布线-按后退两次,angularjs,angularjs-routing,Angularjs,Angularjs Routing,Angularv1.1.5 地点: 我有一个非常简单的路由设置,但是当用户从默认/主路由转到详细(pregunta)路由,然后单击后退按钮时,什么都不会发生。第二次/第三次单击“后退”按钮时,用户返回(chrome)默认/主路线。我不知道这是怎么发生的,为什么会发生 $routeProvider. when('/', { templateUrl: '/js/app/partial/index.html', controller: 'IndexCtrl' }) .when('/pr

Angularv1.1.5

地点:

我有一个非常简单的路由设置,但是当用户从默认/主路由转到详细(pregunta)路由,然后单击后退按钮时,什么都不会发生。第二次/第三次单击“后退”按钮时,用户返回(chrome)默认/主路线。我不知道这是怎么发生的,为什么会发生

$routeProvider.
when('/', {
    templateUrl: '/js/app/partial/index.html',
    controller: 'IndexCtrl'
})
.when('/pregunta/:id', {
    templateUrl: '/js/app/partial/detalle.html',
    controller: 'PreguntaDetalleCtrl'
}).
otherwise({
    redirectTo: '/'
});
这是两个相关的控制器。我删除了一些似乎不相关的代码(轮询新信息等):

//加载问题索引列表,实际问题加载到父范围中
.controller('IndexCtrl',['$scope','services','data','$modal','navigation','timeFunctions',function($scope,services,data,$modal,navigation,timeFunctions)
{
$scope.noEncodeUrl='0http://tilsa.azurewebsites.net/';
$scope.url=encodeURIComponent($scope.noencodeur);
//控制返回箭头的可见性以返回
navigation.setReturn(false);
}])
.controller('pregundatetaleCtrl',['$scope','$routeParams','services','navigation','graphService','stringFx','$timeout','timeFunctions',function($scope,$routeParams,services,navigation,graphService,stringFx,$timeout,timeFunctions){
$scope.notas=[];
$scope.comentario='';
navigation.setReturn(true);
$scope.loadPregunta=函数(id,loadComments)
{
services.preguntas.getDetalle(id).then(函数(数据)
{
$scope.safeApply(函数()
{
$scope.pregunta=数据;
graphService.setProp('title',$scope.pregunta.pregunta);
$scope.noEncodeUrl='0http://tilsa.azurewebsites.net/pregunta/“+id;
$scope.url=encodeURIComponent($scope.noencodeur);
$scope.preguntaText=stringFx.removeAccent('?'+$scope.pregunta.pregunta+'?');
});
如果(加载注释)
{
$scope.commentTracker={
默认值:{},
跳过:0,
拍摄时间:20
};
$scope.$on('$destroy',函数(e)
{
$scope.stopPolling();
});
$scope.startPolling=函数()
{
//scrollTimeout将存储$setInterval实例的唯一ID
返回$scope.scrollTimeout=timeFunctions.$setInterval(轮询,10000,$scope);
//在作用域可用的时间间隔上调用函数
函数轮询($scope)
{
services.preguntas.getNotas($scope.pregunta.id,$scope.commentTracker,$scope.notas)。然后(函数(数据)
{
$scope.safeApply(函数()
{
对于(i=0,l=data.notas.length;i0;
});
});
}
$scope.cargarAnteriores();
}
});
}
$scope.notaNueva=函数(){
//$scope.commentario;
如果($scope.comentario.length<3)
{
警报(“描述算法,无海洋,无海洋,无海洋”);
返回;
}
$scope.processing=true;
services.preguntas.insertNota($scope.pregunta.id,$scope.comentario,$scope.notas,false)。然后(函数(数据)
{
$scope.comentario='';
$scope.processing=false;
$scope.loadPregunta($scope.pregunta.id,false);
services.preguntas.getNotas($scope.pregunta.id,$scope.commentTracker,$scope.notas)。然后(函数(数据)
{
$scope.safeApply(函数()
{
对于(i=0,l=data.notas.length;i
你的应用程序的角度看起来不错

99%的问题是由某些外部库引起的。当然,这个脚本有一些问题(看起来是facebook插件),因为它无法加载某些资源(404错误):您正在查找的资源已被删除、名称已更改或暂时不可用。因此,还会产生两个进一步的错误(请看控制台)。反过来,它会阻止应用程序调用
window.location.hostname.replace
脚本中实际存在的内容


因此,我的建议如下:从您的站点删除此fb插件,并检查
路由是否正常工作…

您的应用程序的角度似乎很好

99%的问题是由某些外部库引起的。当然,这个脚本有一些问题(看起来是facebook插件),因为它无法加载某些资源(404错误):您正在查找的资源已被删除
// load the index list of questions, the actual questions are loaded in parent scope

.controller('IndexCtrl', ['$scope', 'services', 'data', '$modal', 'navigation', 'timeFunctions', function ($scope, services, data, $modal, navigation, timeFunctions)
{
    $scope.noEncodeUrl = 'http://tilsa.azurewebsites.net/';

    $scope.url = encodeURIComponent($scope.noEncodeUrl);
    // controls the back arrow visibility to go back
    navigation.setReturn(false);

}])
.controller('PreguntaDetalleCtrl', ['$scope', '$routeParams', 'services', 'navigation', 'graphService', 'stringFx', '$timeout', 'timeFunctions',  function ($scope, $routeParams, services, navigation, graphService, stringFx, $timeout, timeFunctions) {

    $scope.notas = [];

    $scope.comentario = '';

    navigation.setReturn(true);

    $scope.loadPregunta = function (id, loadComments)
    {
        services.preguntas.getDetalle(id).then(function (data)
        {
            $scope.safeApply(function ()
            {
                $scope.pregunta = data;
                graphService.setProp('title', $scope.pregunta.pregunta);
                $scope.noEncodeUrl = 'http://tilsa.azurewebsites.net/pregunta/' + id;

                $scope.url = encodeURIComponent($scope.noEncodeUrl);
                $scope.preguntaText = stringFx.removeAccent('¿'+$scope.pregunta.pregunta+'?');

            });

            if (loadComments)
            {

            $scope.commentTracker = {
                defaults: {             },
                skip: 0,
                take: 20
            };

            $scope.$on('$destroy', function (e)
            {
                $scope.stopPolling();
            });

            $scope.startPolling = function ()
            {

                // scrollTimeout will store the unique ID for the $setInterval instance
                return $scope.scrollTimeout = timeFunctions.$setInterval(poll, 10000, $scope);

                // Function called on interval with scope available
                function poll($scope)
                {
                    services.preguntas.getNotas($scope.pregunta.id, $scope.commentTracker, $scope.notas).then(function (data)
                    {


                        $scope.safeApply(function ()
                        {
                            for (i = 0, l = data.notas.length; i < l; i++)
                            {
                                $scope.notas.unshift(data.notas[i]);
                            }
                        });



                    });

                }
            }

            $scope.stopPolling = function ()
            {
                return timeFunctions.$clearInterval($scope.scrollTimeout);
            }

            $scope.startPolling();


            $scope.cargarAnteriores = function ()
            {
                //$scope.commentTracker.skip++;

                services.preguntas.getNotas($scope.pregunta.id, $scope.commentTracker, $scope.notas, true).then(function (data)
                {
                    $scope.safeApply(function ()
                    {
                        $scope.notas = $scope.notas.concat(data.notas);
                        $scope.masNotas = $scope.notas.length > 0;
                    });


                });

            }

            $scope.cargarAnteriores();
            }

        });

    }



    $scope.notaNueva = function () {
        //$scope.commentario;


        if ($scope.comentario.length < 3)
        {
            alert('Escribe algo mas, no seas tacano con tus palabras');
            return;
        }
        $scope.processing = true;

        services.preguntas.insertNota($scope.pregunta.id, $scope.comentario, $scope.notas, false).then(function (data)
        {

            $scope.comentario = '';
            $scope.processing = false;

            $scope.loadPregunta($scope.pregunta.id, false);

            services.preguntas.getNotas($scope.pregunta.id, $scope.commentTracker, $scope.notas).then(function (data)
            {

                $scope.safeApply(function ()
                {
                    for (i = 0, l = data.notas.length; i < l; i++)
                    {
                        $scope.notas.unshift(data.notas[i]);
                    }
                });

            });

        });
    }

    $scope.loadPregunta($routeParams.id, true)

    $scope.$on('updatedpregunta', function (event, obj)
    {
        $scope.loadPregunta(obj, false)

    });

}]);
<iframe src="{{selected.url}}"></iframe>
<iframe ng-src="{{selected.url}}"></iframe>