fredericojesus / mygroceries-angular

Testing Angular+Gulp+Angular-Material-Design with a simple shopping list app
3 stars 1 forks source link

Where put my routes ?? #1

Closed cristianounix closed 7 years ago

cristianounix commented 7 years ago

can you show a example ?

fredericojesus commented 7 years ago

@cristianounix you could use ui-router. You can see an example of it in one other project I made here. You can install ui-router via bower or npm and don't forget to add 'ui.router' to your app dependencies.

cristianounix commented 7 years ago

@fredericojesus, so... can i do that in app.config.js


angular
    .module('app')
    .config(function ($stateProvider, $urlRouterProvider, $httpProvider) {
        $httpProvider.interceptors.push('authInterceptor');
        $urlRouterProvider.otherwise('/home');
        $stateProvider
            .state({
                name: 'dumps',
                url: '/dumps',
                templateUrl: './pages/dumps/list.html',
                controller: 'dumpsPageController'
            });
    })
    .config(configure);

  function configure($mdIconProvider) {
      $mdIconProvider
          .iconSet('navigation', '/src/images/material-design-icons/navigation-icons.svg', 24)
          .iconSet('action', '/src/images/material-design-icons/action-icons.svg', 24)
          .iconSet('content', '/src/images/material-design-icons/content-icons.svg', 24);
  }

Would it be a good practice? or have you a better method ?

Thanks man !

fredericojesus commented 7 years ago

If you have a lot of configs to do and a lot of routes it's better to keep them in separate files, in order to make things better organized. But if you're making just a simple application that's OK.

Your welcome! :D

cristianounix commented 7 years ago

Can you write an a example of route in this project ?

fredericojesus commented 7 years ago

OK, I'll try to do it if I have some time.

fredericojesus commented 7 years ago

Done! I added ui-router and a route example, now you can navigate in the items and shopping list options in the nav bar. (see last commit if you want to see the changes I made) I had to also add connect-modrite to the gulp serve file so that we don't have to use the routes like /#/items but rather just /items. So you will have to run npm install and bower install again.