Skip to content

draco1989/bower-angular-fosjsrouting

Repository files navigation

Angular-FosJSRouting

Provides AngularJS support for FOSJsRoutingBundle.

Installation

Include main script in your html

<script type="text/javascript" src="path/to/angular-fosjsrouting/angular-fosjsrouting.min.js"></script>

Usage

Import fosjsrouting in your angular module.

    angular.module('MyModule', ['fosjsrouting']);

Configure it throught $routingProvider

    angular.module('MyModule', ['fosjsrouting']).
            config(function ($routingProvider) {
                $routingProvider.setDefaultParams({
                    '%user_id%': 3
                });
            });

This package includes AngularJS configurable filter and service/provider.

Filter

To generate a simple path

    <a href="{{ 'my_symfony_path_name'|routing }}">Go home</a>

To generate a path with parameters

    <a href="{{ 'hello_user_path_name'|routing:{'%user%':'David'} }}">Go home</a>

To generate an absolute path with parameters

    <a href="{{ 'hello_user_path_name'|routing:{'%user%':'David'}:true }}">Go home</a>

Service

To generate a simple path

    angular.module('MyModule', ['fosjsrouting']).
            controller('Ctrl', function ($scope, $routing) {
                $scope.path = $routing.generate('my_symfony_path_name');
            });

To generate a path with parameters

    angular.module('MyModule', ['fosjsrouting']).
            controller('Ctrl', function ($scope, $routing) {
                $scope.path = $routing.generate('hello_user_path_name', {'%user%': 'David'});
            });

To generate an absolute path with parameters

    angular.module('MyModule', ['fosjsrouting']).
            controller('Ctrl', function ($scope, $routing) {
                $scope.path = $routing.generate('hello_user_path_name', {'%user%': 'David'}, true);
            });

About

AngularJS support for FriendsOfSymfony Javascript routing module.

Resources

License

Stars

Watchers

Forks

Packages

No packages published