javascript - Integrating Angular App within Laravel PHP - Unhandled Exception -
i have laravel app i'd add in angular frontend.
my index file, main.blade.php, specifies name of app. here structure of main page... html partials piped in through {{ $content }}:
<!doctype html> <html lang="en" ng-app="myapp"> <head> ... </head> <body> <div id="main-container"> <header> ... </header> {{ $content }} <footer> ... </footer> </div> </body> </html>
i have partial page, private events:
<div id="inner-container" class="events" ng-controller="myctrl"> <li ng-repeat="phone in phones"> <p>{{phone.name}}</p> </li> ... </div>
and controllers.js file:
var myapp = angular.module('myapp', []); myapp.controller('myctrl', function($scope) { $scope.phones = [ {'name': 'nexus s', 'snippet': 'fast got faster nexus s.'}, {'name': 'motorola xoom™ wi-fi', 'snippet': 'the next, next generation tablet.'}, {'name': 'motorola xoom™', 'snippet': 'the next, next generation tablet.'} ]; });
i'm getting unhandled exception: error rendering view: [content.private-events]. use of undefined constant phone - assumed 'phone'
given file structure, can't link in angular app that? have add controller name tag, or can use dom element container?
thanks
you need change angularjs curly braces not conflict blade template engine:
var app = angular.module('app', []) .config(function($interpolateprovider) { // prevent conflict of `{{` , `}}` symbols // between blade template engine , angularjs templating need // use different symbols angularjs. $interpolateprovider.startsymbol('<%='); $interpolateprovider.endsymbol('%>'); });
i suggest use <%= %>
because it's used construction, can find in underscore templates.
after angular code this:
<li ng-repeat="phone in phones"> <p><%= phone.name %></p> </li>
Comments
Post a Comment