16.07.2017 Views

AngularJS Essentials

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 6<br />

deferred.resolve(result);<br />

} else {<br />

deferred.reject("No results were found!");<br />

}<br />

}, 1000);<br />

return deferred.promise;<br />

};<br />

var _matches = function (entity, criteria) {<br />

return angular.toJson(entity).indexOf(criteria) > 0;<br />

};<br />

return {<br />

filter: _filter<br />

}<br />

});<br />

Now that our search module is ready, we can use it with any project we want! The<br />

name of this script, after the files, concatenation, will be search.js, and we need to<br />

import it to the index.html file.<br />

The parking application module<br />

It's time to create our application module and declare our new modules ui and<br />

search as our dependencies. Also, we need to include the ngRoute and ngAnimate<br />

modules in order to to enable the routing and animation mechanisms. Consider the<br />

following code snippet in the app.js file:<br />

var parking = angular.module("parking", ["ngRoute", "ngAnimate", "ui",<br />

"search"]);<br />

That's it! Now, we just need to import the scripts inside our index.html file,<br />

as follows:<br />

<br />

<br />

<br />

[Packt] Parking<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

[ 119 ]<br />

www.it-ebooks.info

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!