简体   繁体   中英

How do I handle my routing for angular dynamic site

I am new to angular, and I have a content managed and all I want angular for is to handle the routes and show content.

So I want one route; some thing like .when('/{any?}')

And my backend (laravel) will handle all processing and just send back the content. I dont want to have to pre define my routes.

However because that route covers pretty much anything, it doesn't reload any content.

does anyone have any ideas as to the best approach?

If you don't need to define other routes, You can use "otherwise" command, like Florian was recommended:

var app = angular.module("app", ['ngRoute'])
.config(
  function($routeProvider, $locationProvider){
    $routeProvider
    .otherwise({ 
      templateUrl : 'ng-home', 
      controller : 'homeController'
      });
  });

app.controller('homeController', function($scope){
});

Do you make a single test on jsfiddle or plunk? I'm understand your question, but I need a code to help you on your question.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM