leos/angular-ui-routing-bundle

将 Angular UI-ROUTER 集成到 Symfony2 中使用

dev-master / 0.1.x-dev 2015-06-17 09:09 UTC

This package is auto-updated.

Last update: 2024-09-24 03:56:21 UTC


README

将 Angular UI-ROUTER 集成到 Symfony 中使用

基于: https://github.com/angular-ui/ui-router

配置方法

在 AppKernel 的数组 bundles 中添加插件

new Leos\AngularRoutingBundle\LeosAngularRoutingBundle()

在模板中

在 JS 块中添加链接,并将 "my-mode" 替换为您的模块名称,例如

Angular UI 路由器

  • @LeosAngularRoutingBundle/Resources/public/js/vendor/angular-ui-router.js

添加到 routing.yml

leos_angular_routing

  resource: "@LeosAngularRoutingBundle/Resources/config/routing.yml"

  prefix:   /your-prefix

自定义配置 JS

<script src="{{ path('leos_angular_routing_v1', {"module": "my-mode"}) }}"></script>

在 config.yml 或 config_%env%.yml 中定义您的配置站点

# 配置

leos_angular_routing

routes:                                     

    home:                                   #The State Name
        url: ''                             #The url name (Not prefix with "/")
        
        #The template to include
        templateUrl: home                      #The symfony route name
        #Add parameters to the route
        urlParams:
            offer: wellcome
        #The childs
        views:
            partial1:                       #The partial name(unique)
                column: slider              #The column to insert the view
                viewParent: parnetSate      #Optional config to set nestead views
                templateUrl: slider         #The symfony route name
            #Other examamples
            partial2:
                column: aside
                templateUrl: todo
                
            partial3:
                column: content
                templateUrl: todoDisplay

    #To add Sub States
    testContainer:
        url: lobby
        templateUrl: testContainer

    testContainer.subrute:
        url: my-list
        templateUrl: todoDisplay

    testContainer.account:
        url: my-account
        templateUrl: testContainer.account
    #OR
    testContainer:
        url: lobby
        templateUrl: testContainer
        childs:
            subrute:
                url: my-list
                templateUrl: todoDisplay
                childs:
                      cagada:
                          url: cagada
                          templateUrl: todoDisplay
            account:
                url: my-account
                templateUrl: testContainer.account
        
    #To add states with parameters
    play:
        url: 'play/:gameId'
        templateUrl: game

额外内容

测试应用程序的路由控制器

仅当您想调试路由器时才添加它

  • @LeosAngularRoutingBundle/Resources/public/js/Controller/RoutingController.js

使用方法:ng-controller="routing"

加载条

基于: https://github.com/chieffancypants/angular-loading-bar

  • @LeosAngularRoutingBundle/Resources/public/js/vendor/angular-loading-bar.js