search

Home  >  Q&A  >  body text

angular.js - Routing issues caused by building a website with AngularJS+Laravel

I have been learning AngularJS for the past month or so and found that AngularJS is really easy to use. Its two-way data binding, instructions, modularization, and MVC design pattern not only greatly reduce the amount of code required for front-end development, It also makes testing easier.
Before learning AngularJS, I also learned Laravel, a powerful back-end framework. Needless to say, Laravel is very easy to use. So I wondered if it would be better to combine the two, and then I searched online for information about this aspect. The following are some of the more useful websites for information

I also conducted experiments as mentioned above and had success, but I encountered a more difficult problem, that is, AngularJS and Laravel both have their own routing, and AngularJS’s routing is more flexible (using ui-router ); After AngularJS uses ui-router, its routing is based on state, which is very convenient for routing on a page. Perform multiple state conversions, so I wanted to use Laravel routing to jump between pages, and use AngularJS routing to jump within the page; unfortunately, it has never been successful, because Laravel's page template is a PHP file, but AngularJS's The template is an HTML file, so it has never been able to be placed in the ui-view in the Laravel template. I also tried to modify the template file type of the view in Laravel, but with no success. I wonder if anyone has a good method, please share it!

漂亮男人漂亮男人2776 days ago645

reply all(4)I'll reply

  • 黄舟

    黄舟2017-05-15 16:52:34

    Get the view:

    // angular
    ...
    {
        url: 'post',
        templateUrl: 'tpl/post'
    }
    ...
    
    // laravel
    Route::get('tpl/post', function() { return view('tpl/post')});
    

    My tutorial column: /blog/bys

    reply
    0
  • 阿神

    阿神2017-05-15 16:52:34

    You can refer to
    https://phphub.org/topics/181

    reply
    0
  • 天蓬老师

    天蓬老师2017-05-15 16:52:34

    Beginners are advised not to use front-end routing first, make good use of back-end routing first, and then decide whether to use front-end routing based on business combination

    reply
    0
  • 迷茫

    迷茫2017-05-15 16:52:34

    You can learn jquery. It’s easier to learn. Don’t learn those that seem advanced. In fact, it’s of no use in ping shpingsh

    reply
    0
  • Cancelreply