javascript

  • Actually there is another (maybe better solution) where you can use the angular’s native ‘filter’ filter and still pass arguments to your custom filter.
  • Consider the following code:

    To make this work you just define your filter as the following:

    As you can see here, weDontLike actually returns another function which has your parameter in its scope as well as the original item coming from the filter.

  • It took me 2 days to realise you can do this, haven’t seen this solution anywhere yet.
  • Checkout Reverse polarity of an angular.js filter to see how you can use this for other useful operations with filter.

Actually there is another (maybe better solution) where you can use the angular’s native ‘filter’ filter and still pass arguments to your custom filter.
Continue reading “javascript”

Exchange Data Between Directive and Controller in AngularJS

  • The project required me to write a directive for a canvas, get the Base64 image data when a user draws on it, and make it available to the controller of the page which contains the directive.
  • This boils down to the fact that you need to access the scope of a Directive from a page Controller and access the scope of a page Controller from a Directive.
  • Now let’s say we have the following controller:

    And the following template:

    The problem: we would like to bind the count variable of myCtrl to the internalCount variable of the counter directive.

  • This can easily be solved by binding a variable from the controller to the scope of the directive.
  • Your directive should now look like this:

    And your template like this:

    You will find a working fiddle here with all the code to this quick tutorial on how to exchange data between a directive and controller in AngularJS.

In this Quick Tutorial we will look at How to Exchange Data Between Directive and Controller in AngularJS and bind the scopes to each other.
Continue reading “Exchange Data Between Directive and Controller in AngularJS”

Exchange Data Between Directive and Controller in AngularJS

  • The project required me to write a directive for a canvas, get the Base64 image data when a user draws on it, and make it available to the controller of the page which contains the directive.
  • This boils down to the fact that you need to access the scope of a Directive from a page Controller and access the scope of a page Controller from a Directive.
  • Now let’s say we have the following controller:

    And the following template:

    The problem: we would like to bind the count variable of myCtrl to the internalCount variable of the counter directive.

  • This can easily be solved by binding a variable from the controller to the scope of the directive.
  • Your directive should now look like this:

    And your template like this:

    You will find a working fiddle here with all the code to this quick tutorial on how to exchange data between a directive and controller in AngularJS.

In this Quick Tutorial we will look at How to Exchange Data Between Directive and Controller in AngularJS and bind the scopes to each other.
Continue reading “Exchange Data Between Directive and Controller in AngularJS”

Exchange Data Between Directive and Controller in AngularJS

  • The project required me to write a directive for a canvas, get the Base64 image data when a user draws on it, and make it available to the controller of the page which contains the directive.
  • This boils down to the fact that you need to access the scope of a Directive from a page Controller and access the scope of a page Controller from a Directive.
  • Now let’s say we have the following controller:

    And the following template:

    The problem: we would like to bind the count variable of myCtrl to the internalCount variable of the counter directive.

  • This can easily be solved by binding a variable from the controller to the scope of the directive.
  • Your directive should now look like this:

    And your template like this:

    You will find a working fiddle here with all the code to this quick tutorial on how to exchange data between a directive and controller in AngularJS.

In this Quick Tutorial we will look at How to Exchange Data Between Directive and Controller in AngularJS and bind the scopes to each other.
Continue reading “Exchange Data Between Directive and Controller in AngularJS”

AngularJS Isolated Scope Directives

  • In AngularJS by default directives get the parent scope.This will useful when we are exposing the parent controller’s scope to directives.
  • But in some cases your directives may want to add several properties and functions to the scope.If we are doing this than we are populating parent scope itself.
  • Isolated scope directive is a scope that does not inherit  from the parent and exist on its own.
  • Solution:  Just add the scope:{} property in the custom directives.
  • By isolating the scope we guarantee that the directive is self contained and can be easily plugged into an HTML app.Isolating the scope does not mean that you have no access to the parent scope’s properties.

Gulp is a tool for task automation. Gulp helps in many automated tasks like parsing, watching files for changes, refreshing, bundling and minification, executing tests before bui…
Continue reading “AngularJS Isolated Scope Directives”

Why you should use AngularJS instead of Angular 2

  • Also, when I started with the offical Angular websites https://angularjs.org/ and https://angular.io/ and followed the recommendation:

    I spent several days using the various resources learning Angular 2 based on the above websites and faced a lot of difficulties.

  • Finally, I realized that learning Angular 2 to start taking advantage of the newly added feature, will cost me a lot of time and effort.
  • The main reason for posting this question is that we are working on a very critical project which requires a lot of effort and will take a at least one year to migrate the basic product features form the legacy platform to AngularJS or Angular 2.
  • What is mentioned there is that Angular 2 is in developer preview:

    However, the official websites doesn’t mention that.

  • So my recommendation to you is you have enough time to spend in learning Angular 2 and deal with the issues that might show-up then of course this is the recommended path, otherwise, best to stay with AngualrJS.

I am clarifying this question after I have been developing SPA for the past 5 months using AngualrJS. In the beginning, I was researching if I should start with Angular 2 instead.
Continue reading “Why you should use AngularJS instead of Angular 2”