Skip to content

Commit

Permalink
Merge pull request zurb#231 from zurb/221-nav-controller
Browse files Browse the repository at this point in the history
Moving nav controller from controllers to app
  • Loading branch information
AntJanus committed Dec 6, 2014
2 parents b6b64ad + bca26b8 commit 0a2a5a1
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 36 deletions.
36 changes: 36 additions & 0 deletions docs/assets/js/angular.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,3 +183,39 @@ angular.module('application')
};
}
]);

angular.module('application')
.controller('NavController', ['$scope', '$state', function($scope, $state) {
$scope.current = $state.current.name;

var routes = angular.copy(foundationRoutes);

//setup autocomplete
$scope.routing = [];
$scope.typedText = '';

if(foundationRoutes) {
angular.forEach(routes, function(r) {
var title = r.title || r.name.replace('.', ' '); //use title if possible
$scope.routing.push(title);
});
}

$scope.selectRoute = function(routeName) {
var title = routeName;
var name = routeName.replace(' ', '.');

//search for route
angular.forEach(routes, function(r) {
if(r.title && r.title === routeName) {
$state.go(r.name);
return;
} else if (name === r.name) {
$state.go(r.name);
return;
}
});

};
}
]);
36 changes: 0 additions & 36 deletions js/angular/controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,39 +17,3 @@ angular.module('application')
}
]);

angular.module('application')
.controller('NavController', ['$scope', '$state', function($scope, $state) {
$scope.current = $state.current.name;

var routes = angular.copy(foundationRoutes);

//setup autocomplete
$scope.routing = [];
$scope.typedText = '';

if(foundationRoutes) {
angular.forEach(routes, function(r) {
var title = r.title || r.name.replace('.', ' '); //use title if possible
$scope.routing.push(title);
});
}

$scope.selectRoute = function(routeName) {
var title = routeName;
var name = routeName.replace(' ', '.');

//search for route
angular.forEach(routes, function(r) {
if(r.title && r.title === routeName) {
$state.go(r.name);
return;
} else if (name === r.name) {
$state.go(r.name);
return;
}
});

};
}
]);

0 comments on commit 0a2a5a1

Please sign in to comment.