Angularjs Use custom attribute to customize your html behaviour



Sometimes you would like to add custom behaviour to our html markup and have a custom function invoke by it.
For example, lets say you're trying to implement google analytics to track specific field that a user interacts with. So we can create a custom directive that push tracking info to google analytics as user interacts with different field.

We can easily do that with angularjs directive as demostrated with code below :-



We create a normal directive and under the link section (Line #18), we use "on" method to listen to specific html event.


For a demo, please click here.

Comments

Popular posts from this blog

OpenCover code coverage for .Net Core

ionic2 cordova build android - Unable resolve gradle 2.2.3

Using Custom DLL with IronPython / Scripts