Angular.js前端开发路由发生改变但是界面没有改变的情况。
给我你的怀抱
给我你的怀抱 2017-05-15 17:01:55
0
4
674

首先,我用的是ng-switch控制界面的显示,然后在新建地域这个按钮上直接定义herf="/region#create",然后通过改变ng-switch的值来显示不同的界面,但是我不知道为什么会出现这种情况,如下图,就是,点击有时候点第一下的时候界面不跳转,只是刷新了一下,然后路由发生了变化,所以肯定是我在通过配置不同的ng-switch显示界面的时候路由没有配置好产生的问题,所以,我想让大家帮我想想应该从哪些角度来解决这个问题,因为控制台也没有显示,然后点击那个按钮函数又执行了,只是没有ng-switch的值也改变了,就是没有跳转到应该跳转的界面,而且这种错误是一次正常一次不正常的频率发生的,所以,求各位大神,提供解决问题的思路或者方法,因为代码太多太乱,这里我就不贴代码了,还请大家见谅,如图:图片描述

给我你的怀抱
给我你的怀抱

reply all(4)
洪涛

Open the console, check the error, and finally add, please use chrome to develop angular app

迷茫

I don’t know how to write the code. There is something wrong with your routing jump. Directly using href to jump will definitely cause the page to refresh and the status will be lost. The hash part should be treated as an anchor point. For angular front-end routing, it can be Use ui-router.

伊谢尔伦

I suggest you use ui-router,
routing can be implemented as follows:

$stateProvider
.state('region', {
    url: '/region',
    abstract: true,
    template: '<ui-view></ui-view>',
    controller: 'RegionCtrl',
}).state('region.create', {
url: '/create/:id', //若需要id
templateUrl: 'create.html',
controller: 'RegionCtrl',
});

href is directly href="#create". You can read the official documentation for details. very convenient.

大家讲道理

It is also recommended that you use ui-router

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!