angularjs - controller methods matching ui-router states -
in stateprovider, trying next more restful approach given controllers in angularjs can contain sorts of functions, want encapsulate different routes appropriate part of controller (or if have improve way, please advise)
my current state:
.state('main.align.movements.new',{ permissions: '<logged_in>', url: '/new', views: { '@main': { templateurl: 'app/main/align/movements/new.html', // controller: function($scope){ // $scope.newmovement = new movement() // $scope.save = function(){ // $scope.newmovement.save() // } // $scope.cancel = function(){ // } // } controller: 'movementsctrl.hello' } } });
as can see, commented out of code going write controller pretty big quickly. yet, depend on movementsctrl
/index
it's big plenty is. wondering if there way have within movementsctrl
way encapsulate related /new
, /edit
, etc. without having huge ctrl of code (for example, @ /new
want initiate instance of movement
right away don't want initiation persist @ /edit
, don't want ugly , $stateparams
check path given doing $stateprovider
anyways )
thoughts?
angularjs angular-ui-router
No comments:
Post a Comment