AngularJS How to dynamically add HTML and bind to controller

后端 未结 5 1519
梦谈多话
梦谈多话 2020-11-28 05:25

I\'m just getting started with angularJS and struggling to figure out proper architecture for what I\'m trying to do. I have a single page app but the URL always sh

5条回答
  •  孤城傲影
    2020-11-28 05:54

    See if this example provides any clarification. Basically you configure a set of routes and include partial templates based on the route. Setting ng-view in your main index.html allows you to inject those partial views.

    The config portion looks like this:

      .config(['$routeProvider', function($routeProvider) {
        $routeProvider
          .when('/', {controller:'ListCtrl', templateUrl:'list.html'})
          .otherwise({redirectTo:'/'});
      }])
    

    The point of entry for injecting the partial view into your main template is:

提交回复
热议问题