How to make routing of a symfony application in angular js ,I have a symfony application with its templates and I can make the routing of the templates of this application by angular js
thanks you
I am not quite sure what you mean to ask, but probably you are looking for a way to access your Symfony routes in Angular.
In that case, take a look at the
FOSJsRoutingBundle
It provides a javascript object that you can use to generate urls much like the path() function in Twig. For example:
Routing.generate('your_route', {'foo': 'bar'})
You only need a few steps in order use use.
Related
Currently we have application developed in Angular 1.X but we don't want to migrate from Angular 1.X to Angular 2, Since it is very wast application it will require more effort. We want other way around . Can we use Angular 2 features within Angular 1.X Application. In future whichever pages is created should be in Angular 2 but need to be worked side by side with Angular 1.X .. Like calling new route or new component from Angular 2 from Angular 1.X. Please let me know whether its possible or not.
Thanks
Kind of. What you are looking for is an Angular Hybrid app. Here's an article to help with what you are looking for.
Yes, it is possible.
You can use the new angular components/modules in a legacy angular application (downgrading) or you can use legacy components in the a new angular application (upgrading).
There is a section on the angular webpage describing all this. Direct link is here
https://angular.io/guide/upgrade#using-angular-components-from-angularjs-code
I´d like to know if exists a better way to render a view like this:
For the first load I need bring data from Controller like usual but after apply a filter in same page I need to start use AngularJS and never more uses Razor.
Is there a way to do that ?
Thanks for all.
Yes. you can do that.
Basically, you'd need to add the line below in your view. After you do that, the json is going to be available to the DOM / javascript and angular can take it from there. Hope this help
var json = '#Html.Raw(Model.MyJsonStringForMyCoolAngularJsApp)';
There are multiple ways to implement ASP.Net MVC with AngularJs.
I personally like Mini SPA (Silos). You can watch Miguel A Castro's video here.
You can also download the source at his website.
What it does is when a request comes in, it goes to ASP.Net MVC Route first. Then, Angular Route takes over the rest. It is a very slick design.
FYI: I also use Angular.Net Helpers to generate strongly typed views.
You could use WebAPI project in visual studio to exchange data between frontend and backend. It would go stateless, so to secure the data, you could use a mechanism like JWT.
The frontend would exchange JSONS from/to the backend using REST apis.
Yes. You can make angular views and exchange data using $http.get(/controller/method/). You can also configure routing using ngRoute.
I'm newbie web developer and I wonder what better and if it is a good question at all
I can retrieve the information that I need from the server side and make the template with angular, and I can do it with symfony too. whats better? whats the difference? when to use what?
what about forms? should I do it with symfony features or just with angular?
Please look the following points
You should use Angularjs template system. otherwise, the powerful feature of Directives.
Angularjs is decoupled with serverside code.
Angularjs only expects data (as JSON) from service end..not any HTML.
So template should be angularjs way.
So every service response from symfony should be JSON.
Angularjs totally avoiding to add HTML containers (through ajax) into web
pages. So here you can not use symfony template.
As mentionned in the title I want to use angularJS with Symfony1.4.
Is that possible? and How to integrate this framework with Symfony1.4?
Of course you can.
If you are familiar with AngularJS you should now that the important things to be considered is to import correctly the script files, and to declare correctly your app and controller.
The same has to be done in Symfony, importing scripts and declaring Angular app.
I'm actually using it, and it works great.
you dont need integrate Angular with Symfony because Angular is a Javascript framework (client) and Symfony its a PHP Framework (Server). simply you can make a API with symfony a simple static entry point for start the angular application and use the API from the Angular App
So I am planning out an app of moderate complexity using Angular for the frontend and Lithium for the backend. I'm full of questions at this point, but for this post I would like some ideas on templating. Both lithium and Angular have the capacity to handle the entire view layer, but I'd rather treat it like a single page app, so Angular will handle this.
Now how would I handle routes? Would Lithium basically be dumb of the current routes beyond the index? Should API endpoints have a special url scheme separate from the view URLs?
This is how I am thinking now::
theapp.com/dashboard/calendar/event/eventID :: for a view handled by Angular
&
theapp.com/api/event/eventID :: for an API endpoint
I'm quite new to building something this complex so please forgive me if this is a simple question. :)
Am I totally off the mark?
This presentation should be helpful: http://li3-angular.lithium-framework.com/
What you're planning is the way to go: Li3 expose a json api, and Angular handles your routes and views. Your URL scheme should follow REST principles.
li3_resources will help you to build a RESTful api: https://github.com/nateabele/li3_resources
Angular UI router should help you with your routes: https://github.com/angular-ui/ui-router