AngularJS is great. I personally think it is an upgrade from jQuery.
I have been testing AngularJS with Symfony2. One of the problems to build a web application with these two frameworks is that Symfony2's twig language uses the same symbol operator.
For example: PHP uses <?php ?>, AngularJS uses {{ }}, and Symfony2's twig uses {{ }} as well.
The solution is to change the default AngularJS symbol to something else.
After your page finish loading the AngularJS, in your script, add the following function:
angular.module('apps', [])
.config(['$interpolateProvider', function ($interpolateProvider) {
$interpolateProvider.startSymbol('[[');
$interpolateProvider.endSymbol(']]');
}]);
It change the symbol operator from using {{ }} to using [[ ]].
Remember, you also need to define your app in your html code inside the <html>. In this case, I define the AngularJS app to use apps, therefore, in my <html ng-app>, I need to define it using <html ng-app="apps">
Have fun coding!
No comments:
Post a Comment