Angularjs


AngularJS - Why is there an ! in my url now?

Note: This post applies to AngularJS. The 1.x version of Angular. AngularJS has been end of life at of 12/31/2021.

Recently, I upgraded one of my apps to AngularJS 1.6 along with a bunch of other changes and a bunch of my routes broke. Unfortunately, I didn’t catch the routing issue before making a bunch of other changes. The one thing I noticed for all of the broken routes is the urls now had an #! (https://myapp.com/#!/) in them instead of just the # (https://myapp.com/#/). I thought maybe I had done something in one of my changes. Low and behold though, it was not something I did but was a breaking change in AngularJS 1.6 per the AngularJS version migration guide. Thankfully the fix to revert the functionality to the previous version of AngularJS was really easy.

Read More


AngularJS - Calling Filters in Your Angular Controller

Note: This post applies to AngularJS. The 1.x version of Angular. AngularJS has been end of life at of 12/31/2021.

Here is a quick tip for how to call a filter from within your Angular controller. This example assumes that you already know what a filter is and have one created.

  1. Inject $filter into your controller

    angular.module('sample').controller('SampleController', SampleController);
    
    /* @ngInject */
    function SampleController($filter) {
    }
    
  2. Call your filter by calling:

    • View call your filter called “myFilter” on myDateVariable with arguments arg1 and arg2, you would use:
    <p>{{myDateVariable | myfilter : arg1 : 'arg2' }}</p>
    
    • Controller call the same filter from within your controller:
    function SampleController($filter) {
        var value = $filter("myFilter")(myDateVariable, arg1, arg2);
    }
    

Read More


AngularJS - Communicating Between Parent And Child Scopes

Note: This post applies to AngularJS. The 1.x version of Angular. AngularJS has been end of life at of 12/31/2021.

Here is a quick tip in Angular on how to communicate between parent and child scopes.

If you have a need to send notification of an event from a parent scope to a child scope, you use $scope.$broadcast to send the event.

$scope.$broadcast("parent event name", dataTo Send);

If you then need to send notification of an event from the child scope back to the parent scope you use $scope.$emit

Read More


AngularJS In Action Book Review

Note: This post applies to AngularJS. The 1.x version of Angular. AngularJS has been end of life at of 12/31/2021.

At the HolidayJs event I won a book and I picked a copy of Angular In Action by Lukas Ruebbelke. I had already been using Angular for a few projects and wasn’t expecting to get much out of the book. Honestly I got it to use as more of a give away at one of my talks but figured I would at least glance through a few chapters of it first. Needless to say I ended up reading the whole book and plan to keep it.

Read More


AngularJS - Calling Service Methods from Console

Note: This post applies to AngularJS. The 1.x version of Angular. AngularJS has been end of life at of 12/31/2021.

Here is a quick tip for how you can run your Angular service and factory methods within the Chrome Dev Tools console. No longer will you have to go through the process of navigating through the UI to trigger a Service/Factory method to run. Now you can just load up the web site and do all of your debugging through the Chrome console.

Read More