search

Home  >  Q&A  >  body text

angular.js - angular loading issue

Write the following route

javascript$routeProvider.when('/tweet/:name?', {
    controller: ArticleController,
    templateUrl: templateUrl
  }).when('/project/:name?', {
    controller: ArticleController,
    templateUrl: templateUrl
  }).when('/technique/:name?', {
    controller: ArticleController,
    templateUrl: templateUrl
  }).when('/about-me', {
    controller:ArticleController,
    templateUrl: templateUrl
  }).otherwise({
    redirectTo: '/tweet'
  });

But the above settings have no effect when the page is opened for the first time
The corresponding view will not be rendered
Probably because the angularjs script is executed after loading the page for the first time
At this time, the page has been loaded, so the view is not rendered
Is that so?
Websiteblog

阿神阿神2774 days ago501

reply all(2)I'll reply

  • 世界只因有你

    世界只因有你2017-05-15 16:52:26

    If the routing is configured, it will be executed when the page is loaded for the first time. You can check the following aspects to see if there are any problems:

    • AngularJS files are imported
    • Whether ng-app has been added to the corresponding location
    • Whether the routing configuration function is written correctly
    • I really can’t do a unit test

    I don’t know if it can solve your problem.

    reply
    0
  • 为情所困

    为情所困2017-05-15 16:52:26

    angular routing will not render all the pages, so when you open the page for the first time, you will go to the /tweet page and other pages will not be rendered

    It will only be rendered when you click on other pages. If /tweet is not displayed, there must be a problem with the code.

    reply
    0
  • Cancelreply