Entradas

Mostrando las entradas etiquetadas como angularjs

AngularJS tips: ng-if versus ng-show

El hombre es el único animal que tropieza dos veces con la misma piedra, y en mi caso lo puedo hacer incluso 5 ó 6 veces, por eso quiero escribir esta entrada acerca del uso de las directivas ng-if y ng-show (y por extensión de ng-hide) de AngularJS . El problema Pero primero lo primero, veamos que hacen estas dos directivas en un breve ejemplo de código. Si ejecutas este código en tu navegador verás que tan sólo aparece un input en pantalla y que el resto de código HTML no se muestra. Esto se debe al uso de las directivas ng-if y ng-show que tienen precisamente esa finalidad, ocultar elementos mientras la evaluación de sus condiciones no se cumplan. En este caso cuando escribimos la palabra "test" en el input, ambos elementos se harán visibles instantáneamente. Pero en este código hay más de lo que parece. Si te fijas en el bloque script al final del body, verás que hay una función asociada al evento onclick de los elementos ocultos. Y si haces click en cada u...

Book review: AngularJS Services

Imagen
The last book I read is  AngularJS Services  by Jim Lavin and published by  Packt Publishing . It is focused on intermediate and advanced topics from  AngularJS . To say a few, the use of services to reduce the code duplication, the improvement of the code structure and the use of useful patterns in a real project. Note : It takes attention on very interesting third party services like Google Calendar or Google Tasks APIs or the MongoLab service to implement the data persistence. Table of contents The need for services Designing services Testing services Handling cross-cutting concerns Data management Mashing in external services Implementing the business logic Putting it all together As you can see the contents are not for the novice on AngularJS, but don't be worried, they are not so advanced and the author explains the details very well. It is focused on developers who had been programming with AngularJS for a few months and they are ready to ta...