How to configure AngularJS

The simplest way to get an AngularFaces application running is to add ng-controller and ng-app to the <body> tag. It's also possible to add the ng-controller to any other JSF component. The important bit is ordinary HTML tags don't work - in particular <div> doesn't. A future version of AngularFaces will fix it (it will allow to use at least the two most popular tags <div> and <span>).

The complete set of attributes to activate AngularJS is shown in this snippet:

<h:body id="angular" 
        ng-app="CarDealer" 
        ng-controller="CarDealerController" 
        angularJSFile="filter.js">

Using ng-controller in a <div>

Due to a bug it's a tad difficult to use ng-controller in a div. You have to replace the <div> by <h:panelGroup>. But since there's a second bug, that still doesn't do the trick. You have to use both:

<h:body id="angular" style="padding-left:10px">
  <form id="myForm" style="width: 700px">
    <h:panelGroup ng-app="CarDealer" ng-controller="CarDealerController" angularJSFile="index.js">
      <div ng-app="CarDealer" ng-controller="CarDealerController">
  

Of course, that's a work-around that will break in AngularFaces 2.1, which fixes both bugs.