background preloader

Angular JS

Facebook Twitter

Instrumenting Angular with Zone – Wintellect DevCenter. In my last post I described an open source tool from the Angular team called Zone that allows you to execute a JavaScript workflow within an execution context. I demonstrated how to instrument a sequence of asynchronous events using Zone. This is a short post to follow-up and illustrate how to do the same thing in Angular. The first step, of course, is to Angular-ize the HTML. This is simple enough. Instead of manually binding a click function, I can use the ng-click directive, and instead of manually setting the data I can use data-binding.

<button id="myBtn" ng-click="populate()">Populate</button> <span id="myData">{{data}}</span> In order to put Angular “into the Zone” we need to capture the bootstrap process. Var main = function() { zone.marker = "main"; console.log('getting injector'); angular.module('myApp', []).run(function($rootScope, $timeout){ zone.marker =< /span> "module run"; $rootScope.populate = function() { zone.marker = "click"; $rootScope.data = "Initializing & nbsp; }, 2000); Zone Profiling with Angular. AngularUI for AngularJS.

Angular Grid - A Data Grid for AngularJS. Stevenh77 (Steven Hollidge) Nberardi/consensus. Projects using AngularJS · angular/angular.js Wiki. GitHub Contributors. Daha/angularJS-github-contributors. Thinkful/guide-intro-to-angular. Jmcunningham/AngularJS-Learning. Angular.js Demos, Examples, and Resources. Built with AngularJS. DanWahlin (Dan Wahlin) Shidhincr/LookAround. Read Practical AngularJS. Introduction This book contains the AngularJS related blog posts posted on Dinis Cruz’ blog at This is the first draft release of this book, so please send your sugesttions, criticisms, ideas or comments to dinis.cruz@owasp.org Notes about current structure The first version of this book had the chapter order created by the original ‘import from blogger’ (i.e. by publish order).

In the current version, the posts are split into the following areas: “Using AngularJS”, “KarmaJS”, “Firebase”, “Misc Tricks”, “IDEs”, “Troubleshooting”, “Appendices”, which is a filter based on technology. Note that this can change based on reader feedback, so if you think the order should be different, please send your feedback and ideas. About the Author Dinis Cruz is a Developer and Application Security Engineer focused on how to develop secure applications. Table of Contents | Code Change log: In 2014, here are the changes made (per version): 1 Using AngularJS The created application is an:

Read Recipes with Angular.js. {{frontmatter}} # Preface Introduction Angular.js is an open-source Javascript MVC (Model-View-Controller) framework developed by Google. It gives Javascript developers a highly structured approach to developing rich browser-based applications which, leads to very high productivity. If you are using Angular.js, or considering it, this cookbook provides easy-to-follow recipes for issues you are likely to face. Each recipe solves a specific problem and provides a solution and in-depth discussion of it. Code Examples All code examples in this book can be found on Github.

If you have questions or comments please get in touch with: Frederik Dietz (fdietz@gmail.com) Acknowledgements Special thanks go to my english editor and friend Robert William Smales! Thanks go to John Lindquist for his excellent screencast project Egghead IO, Lukas Ruebbelke for his awesome videos, Matias Niemela for his great blog. {{mainmatter}} An Introduction to Angular.js Including the Angular.js Library Code in an HTML Page. Angular v2.0. The reason Angular JS will fail. I agree with the premise but disagree with the argument. > Which brings me to the pattern of ever failing technologies. Remember Moo Tools? Prototype? ... That's just not true. > The main reason Angular JS will fail is because it’s difficult.

This is fair criticism, but there's no supporting evidence provided—only that Angular JS didn't "feel" right and that more people search for "Angular sucks" than "jQuery sucks" on Google. I think Angular got a lot of core ideas right: two-way binding and extending HTML.

If you're not careful to fully understand Angular, it's easy for your first Angular app to turn into a mess of spaghetti, since Angular enforces too much awkward structure at the directive/controller levels, and not enough at the data management layer. But these are issues that the Angular core team is well aware of. AngularJS 2.0. Today, after eight months of work, over two thousand commits, nineteen beta and six release candidates, we finally released AngularJS 1.3.0 superluminal-nudge!

This release includes many notable new features: One-time bindings – by prefixing an expression with "::", it will only be interpolated once, and then no longer watched.ngAria – a new module that helps make custom components in Angular more accessible by defaultngMessages – a new directive that simplifies writting and coordinating feedback for on form validityngModelOptions – a directive that makes it easy to customize the behavior of bound models. For instance: debouncing, getter-setter-style models, update-on-blur, and more.Strict DI – an option for finding places in your application that will not minify due to use of short-hand DI syntax Included in this release are over four hundred bug fixes, and nearly one thousand documentation improvements.

You can read the exhaustive list of changes in our changelog on GitHub. Screencasts/introToAngular at gh-pages · curran/screencasts. Screencasts/introToAngular at gh-pages · curran/screencasts. Angular Is Slow. There was a recent post comparing AngularJS to EmberJS and one of the take aways was that AngularJS is fundamentally slower. I’d like to address that.

This has nothing to do with AngularJS vs EmberJS as I think that is a boring discussion and I know nothing about EmberJS. Models in AngularJS One of the great selling points of AngularJS is that the model is just a plain javascript object. Not to spend too much time on this but the reason I enjoy them being separate is that it lets your models be more than something that lives in the database or is the result of a web request. Angular lets you have classes, plain javascript objects, and even just single functions act as “models” with its factories. So a bit of a tangent there, but an important one I think. Dirty Checking Since your models are just plain javascript objects (POJO’s) AngularJS keeps the view model ($scope) and the view in sync via dirty checking. The watch expression here is filteredOrders(). $scope. Rendering This is fast.

Angular directives for Bootstrap. The $uibPosition service provides a set of DOM utilities used internally to absolute-position an element in relation to another element (tooltips, popovers, typeaheads etc...). getRawNode(element) Takes a jQuery/jqLite element and converts it to a raw DOM element. parameters element(Type: object) - The element to convert. returns (Type: element) - A raw DOM element. parseStyle(element) Parses a numeric style value to a number. Value(Type: string) - The style value to parse. (Type: number) - The numeric value of the style property. offsetParent(element) Gets the closest positioned ancestor. element(Type: element) - The element to get the offset parent for.

(Type: element) - The closest positioned ancestor. scrollbarWidth(isBody) Calculates the browser scrollbar width and caches the result for future calls. IsBody(Type: boolean, Default: false, optional) - Is the requested scrollbar width for the body/html element. (Type: number) - The width of the browser scrollbar. position(element, includeMargins)

An approach to use jQuery Plugins with AngularJS | codef0rmer. Lets face it, we can not completely get rid of jQuery and its plugins ecosystem, even though Angular has a built-in subset of jQuery under the name jQLite. At one point or another, we often need some sort of jQuery plugins in our application and we can/should not port entire plugin into Angular world in order to use it but we can avoid the plugin initialization code to be scattered across. How? Simply by writing a directive for it. I would like to give you a small demo of Toolbar.js which is a jquery plugin I found recently on geekli.st. This is how we create a tooltip style toolbar in jQuery: Enter the dragon a.k.a Angular We’ll keep our markup intact by just adding a custom attribute named `toolbar-tip` – which will be an angular directive we’ll going to write soon.

One thing to notice here is that I’ve moved all the options of a toolbar into an HTML so that we can use the same directiv anywhere else with different options/settings. Finally, Woohoo! Demo. What are the nuances of scope prototypal / prototypical inheritance in AngularJS? AngularJS: Is ng-click "a good practice"? Why is there no ng-{event} in AngularJS? "Thinking in AngularJS" if I have a jQuery background?

Welcome to Yearofmoo. Angular Function Declarations, Function Expressions, and Readable Code. We spend more time reading our code than writing it. That’s why it makes sense to write code that is easier to read. The good news is that there are a lot of really simple things that can make your code much more readable. This post describes simple techniques to make AngularJS controllers and services/factories more readable.

For more details on these and other Angular coding styles, please see my Angular Style Guide and my upcoming Pluralsight course “AngularJS Patterns: Clean Code” (Sep 2014). Quiz OK, first let’s take a step back and start with a quiz. Question 1: What will func1() yield? Function func1() { function foo() { return 'foo-top'; } return foo();}func1(); Question 2: What will func2() yield? Function func2() { return foo(); function foo() { return 'foo-bottom'; }}func2(); Question 3: What will func3() yield? Function func3() { var foo = function () { return 'foo-top'; } return foo();}func3(); Question 4: What will func4() yield?

Answers Question 1 The output is foo-top. Question 2. AngularJS Tutorial. AngularJS • TodoMVC. AngularJS — Superheroic JavaScript MVW Framework. Egghead.io - Learn AngularJS with Tutorial Videos & Training @eggheadio. AngularJS — Superheroic JavaScript MVW Framework.

Learn to Build Modern Web Apps with the AngularJS Tutorial | Thinkster. AngularJS. AngularJS VTECL. TechEd NA 2014 – Building Rich Apps with AngularJS on ASP.NET | Sean's Stuff. TechEd North America 2014, Houston Building Rich Apps with AngularJS on ASP.NET – John Papa Day 4, 15 May 2014, 8:30AM-9:45AM (DEV-B420) Disclaimer: This post contains my own thoughts and notes based on attending TechEd North America 2014 presentations. Some content maps directly to what was originally presented. Other content is paraphrased or represents my own thoughts and opinions and should not be construed as reflecting the opinion of either Microsoft, the presenters or the speakers. Executive Summary—Sean’s takeaways John Papa – Tech Evangelist, formerly of Microsoft @john_papawww.johnpapa.net Why AngularJS works Results quicklyBut then you hit wallsThis session is—about getting past these walls10 tips Emotional roller coaster ride Not a smooth ride, need to get past bumps Building large scale apps requires some planning Demos can be found at Agenda Important to know which thing you need Tip 1 – Component hierarchy View HTMLBuilt-in AngularJS directives Controller $scope Data binding Modules Routes.

Built with AngularJS. Scope - What's the correct way to communicate between controllers in AngularJS. API: $rootScope.Scope. Processes all of the watchers of the current scope and its children. Because a watcher's listener can change the model, the $digest() keeps calling the watchers until no more listeners are firing. This means that it is possible to get into an infinite loop. This function will throw 'Maximum iteration limit exceeded.' if the number of iterations exceeds 10. Usually, you don't call $digest() directly in controllers or in directives. Instead, you should call $apply() (typically from within a directive), which will force a $digest(). If you want to be notified whenever $digest() is called, you can register a watchExpression function with $watch() with no listener. In unit tests, you may need to call $digest() to simulate the scope life cycle. var scope = ...; scope.name = 'misko'; scope.counter = 0; expect(scope.counter).toEqual(0); scope.

Understanding Scopes · angular/angular.js Wiki. Executive Summary: Scope inheritance is normally straightforward, and you often don't even need to know it is happening... until you try 2-way data binding (i.e., form elements, ng-model) to a primitive (e.g., number, string, boolean) defined on the parent scope from inside the child scope.

It doesn't work the way most people expect it should work. What happens is that the child scope gets its own property that hides/shadows the parent property of the same name. This is not something AngularJS is doing – this is how JavaScript prototypal inheritance works. New AngularJS developers often do not realize that ng-repeat, ng-switch, ng-view, ng-include and ng-if all create new child scopes, so the problem often shows up when these directives are involved. (See this example for a quick illustration of the problem.) This issue with primitives can be easily avoided by following the "best practice" of always have a '.' in your ng-models – watch 3 minutes worth. The Details: Takeaways: ng-include .

Angular.js example application. Introduction The Demo App Overview Angular.Js IntroductionThe Publisher The Angular.js Website That's It This article is my first one for quite a while, there is a reason for that but I will not bore you all with that. Anyway I have written this article after a little time off.

So what does it do, what is this article about? I decided to spend a bit of time to learn a bit more about a popular web MVC framework by our friends at Google called Angular.js, which is a JavaScript MVC framework, which is a bit of departure for me from my usual XAML influenced world. It is however good to try things out to get an appreciation of how you would do things in different languages/environments (my old mentor Fredrik Bornander (AKA the Swede) told me that), so I decided to take Angular.js for a spin.

This article will talk about some of the fundamental ideas behind Angular.js, and shall then focus on the specifics of the demo application that I have created to go along with this article. Publisher Apps. Getting started with AngularJS - The Problem Solver. Getting started with AngularJS Index: One of the nicer JavaScript frameworks out there to work with must be AngularJS. Now there are quite a few other ones out there and I have used a number of them but AngularJS seems to be the most structured of them. And while it is really powerful it is also really easy to get started with. AngularJS is a client side framework for creating rich web applications using JavaScript and HTML.

The simplest AngularJS application Below is pretty much the simplest AngularJS application you can make. So what does it get to display a “2” on the screen? 1: <! 2: <html lang="en"> 3: <head> 4: <title>AngularJS Demo</title> 5: <meta http-equiv="content-type" content="text/html;charset=UTF-8" /> 6: </head> 7: <body ng-app> 9: <script src="Scripts/angular.js"></script> 10: </body> 11: </html> There are a few interesting things to note about this. First of all there is the required script reference to angular.js. The last interesting part if the {{1 + 1}} part inside the body.

Tutorial: 0 - Bootstrapping. Loading... In this step of the tutorial, you will become familiar with the most important source code files of the AngularJS Phonecat App. You will also learn how to start the development servers bundled with angular-seed, and run the application in the browser. Before you continue, make sure you have set up your development environment and installed all necessary dependencies, as described in the Environment Setup section. In the angular-phonecat directory, run this command: git checkout -f step-0 This resets your workspace to step 0 of the tutorial app. You must repeat this for every future step in the tutorial and change the number to the number of the step you are on.

If you haven't already done so, you need to install the dependencies by running: npm install To see the app running in a browser, open a separate terminal/command line tab or window, then run npm start to start the web server. You can now see the page in your browser. The HTML page that displays "Nothing here yet! " <!