angular.js - Routing issues caused by building a website with AngularJS+Laravel
漂亮男人
漂亮男人 2017-05-15 16:50:34
0
4
637

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

  • Working With a Laravel 4 Angular Application

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!

漂亮男人
漂亮男人

reply all(4)
黄舟

Get the view:

// angular
...
{
    url: 'post',
    templateUrl: 'tpl/post'
}
...

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

My tutorial column: /blog/bys

阿神

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

Peter_Zhu

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

迷茫

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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template