Foundation for Apps : How to replace the default Dynamic Routing plugin?

前端 未结 1 473
臣服心动
臣服心动 2020-12-18 14:48

Zurb\'s Foundation For Apps is using a special plugin that creates routes directly from each view, it will parse all the HTML files to find this kind of mar

相关标签:
1条回答
  • 2020-12-18 15:17

    This solution solved my issue :

    by @escapedcat from this github issue page :

    gulpfile.js: comment out the FA router part :

    // Copies your app's page templates and generates URLs for them
    gulp.task('copy-templates', ['copy'], function() {
      return gulp.src('./client/templates/**/*.html')
        // .pipe(router({ 
        //   path: 'build/assets/js/routes.js',
        //   root: 'client'
        // }))
        .pipe(gulp.dest('./build/templates'))
      ;
    });
    

    index.html: remove the routes.js

    <script src="/assets/js/foundation.js"></script>
    <!-- <script src="/assets/js/routes.js"></script> -->
    <script src='//maps.googleapis.com/maps/api/js?sensor=false'></script>
    <script src="/assets/js/app.js"></script>
    

    app.js: comment out the dynamicRouting modules and modify the config part :

     angular.module('application', [
        ...
        //foundation
        'foundation',
        // 'foundation.dynamicRouting',
        // 'foundation.dynamicRouting.animations',
        ...
        ])
        .config(
          function($stateProvider, $urlRouterProvider) {
            $stateProvider
              .state('yourstate', {
                  url: '/yoururl',
                  templateUrl: 'templates/yourTemplate.html',
                  controller: 'YourController',
                  resolve: {
                      // you can use resolve here, yay!
                      // promiseFooData: ['Restangular', function(Restangular) {
                      //     return Restangular.one('foo').get();
                      // }]
                  }
              });
        })
      .run(run)
    ;
    

    You need a .state entry for each route/template you had before. In this example the part before looked like this :

    ---
    name: yourstate
    url: /yoururl
    controller: YourController
    ---
    

    NOTE: Animation may also be added to state (after version 1.1 I guess) :

    $stateProvider
      .state('home', {
        url: '/',
        templateUrl: 'templates/home.html',
        animation: {
          enter: 'slideInDown',
          leave: 'fadeOut'
        }
      });
    
    0 讨论(0)
提交回复
热议问题