Angular.js front-end development routing changes but the interface does not change.
给我你的怀抱
给我你的怀抱 2017-05-15 17:01:55
0
4
721

First, I used ng-switch to control the display of the interface, and then directly defined herf="/region#create" on the new region button, and then changed the value of ng-switch to display different interfaces, but I don’t know why this happens, as shown below, that is, sometimes the interface does not jump when I click it for the first time, it just refreshes, and then the routing changes, so I must be configuring different ng -The routing is not configured properly when the switch displays the interface. The problem arises, so I want everyone to help me think about how to solve this problem, because the console is not displayed, and then the button function is executed again, but the value of ng-switch has not changed. It just doesn’t jump to the interface it should jump to. Moreover, this kind of error occurs once normally and once abnormally. Therefore, please provide me with ideas or methods to solve the problem. Because the code is too much and too confusing, I will not post the code here. Please forgive me. If Picture: Picture description

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

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