<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[AngularJS Articles - Medium]]></title>
        <description><![CDATA[Decent articles about the popular AngularJS framework - Medium]]></description>
        <link>https://medium.com/angularjs-articles?source=rss----3aae28b413bf---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*qKl4r3bfKjxY8tXD.png</url>
            <title>AngularJS Articles - Medium</title>
            <link>https://medium.com/angularjs-articles?source=rss----3aae28b413bf---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 22:28:24 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/angularjs-articles" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Deep linking in Ionic Mobile Applications]]></title>
            <link>https://medium.com/angularjs-articles/deep-linking-in-ionic-mobile-applications-44d8b4685bb3?source=rss----3aae28b413bf---4</link>
            <guid isPermaLink="false">https://medium.com/p/44d8b4685bb3</guid>
            <category><![CDATA[angularjs]]></category>
            <category><![CDATA[ionic]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Jamie Sutherland]]></dc:creator>
            <pubDate>Tue, 03 Mar 2015 22:49:50 GMT</pubDate>
            <atom:updated>2015-06-04T07:48:56.159Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TYQag9Vi0ELG_7LlaDEuAg.jpeg" /></figure><p>Deep linking inside of cordova apps build with angular is a common request. It’s a fairly easy task to get the deep link URL. Write a global function to handle the call to <a href="https://github.com/EddyVerbruggen/Custom-URL-scheme#3-usage"><strong>handleOpenURL</strong></a><strong> </strong>then do stuff inside of it to move to the correct place in your application. Android users will need this plugin. <a href="https://github.com/EddyVerbruggen/Custom-URL-scheme">https://github.com/EddyVerbruggen/Custom-URL-scheme</a></p><p>Doing this inside of AngularJS and Ionic bring a few extra challenges. First, you have the problem of getting the global call to <a href="https://github.com/EddyVerbruggen/Custom-URL-scheme#3-usage"><strong>handleOpenURL</strong></a> to be handled inside of your Angular application. There are a few solutions out there like fetching the body element, getting the scope and calling a function. I found these to be a bit hacky.</p><p>Next you have to deal with a race condition. The time between <a href="https://github.com/EddyVerbruggen/Custom-URL-scheme#3-usage"><strong>handleOpenURL</strong></a> being called and your application varies greatly if your app is starting from cold or from the background. Some solutions just wait X amount of seconds. As you can guess this isn’t ideal.</p><p>The final problem is with <a href="http://ionicframework.com/">Ionic</a>, well ui-router technically. It has no concept of history inside the state system provides by the router. <a href="http://ionicframework.com/">Ionic</a> fills this gap with their <a href="http://ionicframework.com/docs/api/service/$ionicHistory"><strong>$ionicHistory</strong></a> service. Where this falls down though is in deep linking. If you jump straight to a state even one level deep. It doesn’t know how to come back up that tree. So the ugly hack is to use nested <a href="http://angular-ui.github.io/ui-router/site/#/api/ui.router.state.$state"><strong>$state.go</strong></a> calls, or use modals for the views you want to pop to the front. Again both not ideal.</p><p>So here’s a solution we’re using to tackle these issues to provide deep linking into our application from a custom URL or from push notifications.</p><h4>State Configuration</h4><p>The first change is we need to give our state model an idea of the hierarchy of the states. This will let us page back through states in a predictable way if we jump into any state in our application.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/837ee524d4b66acaa2a4df415f58248e/href">https://medium.com/media/837ee524d4b66acaa2a4df415f58248e/href</a></iframe><p>The state of <strong>tab.feeds/feed</strong> shows that the <strong>tab.feeds</strong> state is a parent of that state. State hierarchy is denoted by the ‘/’.</p><p><em>This is not to be confused with parent concepts inside of ui-router.</em></p><h4>Back Button Directive</h4><p>Now we need some way to workout when we’re deep in our application and how to get us back to the top level view. A directive is perfect for this. The code below creates a back button that only shows when there is a parent view to navigate to but there is no back view in the history.</p><p>The interesting part here is the canGoBack method which checks the current state. Splits it by ‘/’ and works out if there is a fake state to jump back to. It only returns true if there is no back state in history already. The next key part is in the $ionicHistory.nextViewOptions() call. We disable the history and back button. If we didn’t back would actually be forward were we just came from.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7c1ea8126123bc9430791e7a83174f7f/href">https://medium.com/media/7c1ea8126123bc9430791e7a83174f7f/href</a></iframe><p>Using the directive, you’ll want to place it on nested views in between the ion-view and ion-content directives.</p><pre> &lt;ion-view&gt;<br>   &lt;mlz-back-button&gt;&lt;/mlz-back-button&gt;<br>   &lt;ion-content&gt;<br> ….</pre><p><em>// TODO: I’m sure this can be improved by hooking into ionic’s actual back button</em></p><h4>Handling Custom URLs</h4><p>Next we need to take care of the race conditions and global handling when handling custom URLs. When looking at this problem, I was thinking. Why doesn’t this work like the <strong>deviceready</strong> event. Why can’t I attach an eventListener that is triggered if the openURL has already been found and handled.</p><p>A bit of digging revealed that cordova has functionality to create sticky event handlers. So we can use the exact same functionality used to handle the <strong>deviceready</strong> event.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a05deb3b1ce0961e2acbb84d737576b0/href">https://medium.com/media/a05deb3b1ce0961e2acbb84d737576b0/href</a></iframe><p>This code in your main app.js file will handle the global call to handleOpenURL and fire off a cordova document event. This is designed to work with <strong>cordova.addStickyDocumentEventHandler</strong> so that once this event has been fired, the result is stored an any listeners attached to it in the future will be given the historic result. It also works as expected if the listener is attached before the event is trigger. This eliminates the race condition problem</p><h4>OpenUrlService</h4><p>Now we just need something to consume the event as we would any other event and change the location of the application when it’s fired. Note the changes to $ionicHistory. These make sure that view history will not be preserved when jumping into this state. This ensures that our fake back button directive will work from earlier.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1be1b039b35fe6b8de302cb50176bda2/href">https://medium.com/media/1be1b039b35fe6b8de302cb50176bda2/href</a></iframe><h4>Rounding this all up</h4><p>Well I hope this helps someone get there deep link on inside of their Ionic app with ease in a clean, and testable way. The beauty about this is if you keep your urls and state kinda identical when mapping out the states. It makes it super simple to use the same system to deep link using an object from a push notification. But I’ll leave that for later.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=44d8b4685bb3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/angularjs-articles/deep-linking-in-ionic-mobile-applications-44d8b4685bb3">Deep linking in Ionic Mobile Applications</a> was originally published in <a href="https://medium.com/angularjs-articles">AngularJS Articles</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AngularJS UI Table View]]></title>
            <link>https://medium.com/angularjs-articles/angularjs-ui-table-view-63ce4f03f2e?source=rss----3aae28b413bf---4</link>
            <guid isPermaLink="false">https://medium.com/p/63ce4f03f2e</guid>
            <dc:creator><![CDATA[Jamie Sutherland]]></dc:creator>
            <pubDate>Mon, 04 Aug 2014 15:00:38 GMT</pubDate>
            <atom:updated>2014-08-04T15:00:38.363Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KA0EfxEUUL53q92xykaLLQ.jpeg" /></figure><h4>AngularJS virtual scroller designed for mobile first.</h4><h3>Yea yea, blah blah blah, I just want the scroller!</h3><p>For those that just want to get stuck in. Proceed forthwith.</p><p><a href="http://angular-ui-table-view.mallzee.com/">http://angular-ui-table-view.mallzee.com</a></p><p>Check it out, fork it, fix it, or chat to me about it on twitter. <a href="http://twitter.com/wedgybo">@wedgybo</a>.</p><h3>Why are we talking about another scroller?</h3><p>There are plenty of virtual scrollers out there these days. So why have I gone to the bother of writing up about another one? Well. Most of the ones out there are designed for the desktop. The ones that I tried, and believe me. I tried many, just weren’t quite right on a mobile device. Plus I wanted to build something for AngularJS that didn’t rely on any external libraries, in the hope that we could make scrolling in our mobile apps glide with grace.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sbvw91WvPn790Qv9b-91Rg.jpeg" /><figcaption>Silky smooth</figcaption></figure><p>There are two major hurdles to get over with mobile.</p><ol><li>Large amounts of DOM in your application kills performance.</li><li>Scrolling events and calculation are hard on mobile</li></ol><p>First you have the same problem that exists on desktop. The reason these virtual scrollers exist in the first place is because loading tens of thousands of DOM elements into your pages kills performance. While displaying a list of ten thousand items on your desktop app might make the browser a little janky when scrolling. It will 100% kill a mobile application.</p><p>Some great people started coming up with solutions by faking the size of the scrolling element to make it appear like the content is huge, but only display enough DOM elements to show on the screen, plus a buffer either side. Then they create and delete elements as you scroll so they appear like it’s one continuous list. Happy days. This solution is great on the desktop and has been for a while now. It’s what we’ve mirrored in this solution.</p><p>Second is mobiles dirty little secret. It doesn’t like you scrolling.</p><blockquote>HTML5 on mobile devices + scrolling big lists = Massive headache.</blockquote><p>There is no continuous scroll event when you flick your view up and down. You get sporadic events, only when your finger is touching the screen. This makes life a hard when you want to create that smooth native feel. So here’s our solution which is trying to get that native feel for HTML5</p><p><a href="https://github.com/mallzee/angular-ui-table-view">https://github.com/mallzee/angular-ui-table-view</a></p><h3><strong>Technical shenanigans</strong></h3><p>The concept is based around <strong>ng-repeat</strong> track by feature to stop DOM creation and deletion, which is slow on mobile devices. Too slow when scrolling.</p><p>The directive is called <strong>mlz-ui-table-view</strong>. It holds all the information about the view, buffer, scroll position, items list, subset of items, etc. This is the only directive required to control your child ng-repeat.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/690/1*9YaMzaYTbxdpgh_TBNmvPQ.png" /><figcaption>Markup to create the virtual list.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/898/1*Cn-hi8y8M1WwF8nR6aI29g.png" /><figcaption>Overview of the scrollers key parts and how it works</figcaption></figure><h4>Scrolling</h4><p>When a scroll event is detected. Models which map the buffer position, view position and scroll position are all updated based on the scrollPos of the container and the specified row height of the items. The key elements here are the position, the scroll directions, and if the direction has changed</p><h4>View</h4><p>The view tracks the position of what the user is actually seeing. This is so we can calculate where the buffered elements should be moved to based on the view’s position and scroll direction.</p><h4>Buffer</h4><p>This is the list of DOM elements that are moved around the scroll wrapper to give the appearance of a full list.</p><h4>Dead Zones</h4><p>These are area’s on the scroller that have no effect on the buffer. If the view’s edges stay in these dead zones, the render process can be skipped.</p><h4>Trigger Zones</h4><p>These are area’s that can trigger events, most commonly used to load more data into the main items array. It can be useful for virtual pagination by triggering a function on your scope when either end is reached.</p><h3>How does it work?</h3><p>The UITableView works by trying to keep the buffer as long as possible in the direction of travel. So if you are scrolling down the list. There is no point in showing anything directly above the view. As soon as there is an index change detected on the top edge, a calculation is made to workout how many indexes we have passed since the last event. Then all those elements are moved to the other end of the list in the correct order and updated with the relative items data to create the illusion of a never ending list.</p><p>When the direction of travel is changed. The buffer automatically jumps as far as possible in the direction of travel. This is to avoid whitespace when the scroll speed gets too high.</p><h3>Performance</h3><p>I’ve got the following FPS graphs from my Chrome Inspector and Instruments. You can see on the mobile device, it’s sitting at an average of 50fps. This was with heavy and varied scrolling. On the desktop it gives it no problems what so ever. I believe the performance can be improved further with a greater understanding and simplifying of ng-repeat specifically for this directive and further improvements to the current code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dYuOCQw4Rk7vVkK8V9ipiw.png" /><figcaption>Running on an iPhone 4s with a list of appox 200 items. Buffer size = 10 elements each with a height of 150px</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nX9Ol7kc7R28PDFBxxmA3Q.png" /><figcaption>Chrome 32 on a 2011 Macbook Pro running Lion</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=63ce4f03f2e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/angularjs-articles/angularjs-ui-table-view-63ce4f03f2e">AngularJS UI Table View</a> was originally published in <a href="https://medium.com/angularjs-articles">AngularJS Articles</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Authentication with AngularJS]]></title>
            <link>https://medium.com/@mattlanham/authentication-with-angularjs-4e927af3a15f?source=rss----3aae28b413bf---4</link>
            <guid isPermaLink="false">https://medium.com/p/4e927af3a15f</guid>
            <dc:creator><![CDATA[Matt Lanham]]></dc:creator>
            <pubDate>Sun, 05 Jan 2014 12:30:07 GMT</pubDate>
            <atom:updated>2014-04-09T13:03:34.296Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UUkVbGnfE2hCy6sggHA2EQ.png" /></figure><h4>Simplify your user authentication when using ui-router</h4><p>Managing authentication within your AngularJS application is extremely important, initially I found it quite difficult to find some examples of how to do it the right way for my startup <a href="http://www.enquiryhq.com/">http://enquiryhq.com</a>, keeping the logic clean, and as automated as possible.</p><p>Initially I just rolled some convoluted solution using the $rootScope to store variables, and then access those variables within my controllers, but it was messy, and created a lot of duplicate code.</p><p>So I was pointed to an <a href="http://blog.brunoscopelliti.com/deal-with-users-authentication-in-an-angularjs-web-app">article</a> on the subject (thanks <a href="http://twitter.com/gdi2290">@gdi2290</a>) that had a better example of how to do this, but it wasn’t setup for <a href="https://github.com/angular-ui/ui-router">ui-router</a>, so I had to adapt it a little to work with it.</p><p>First of all I adjusted my routes to the following: (note the addition of the authenticate property)</p><pre>myApp.config(function($stateProvider, $urlRouterProvider){<br>  $stateProvider<br>    .state(&quot;forms&quot;, {<br>      url: &quot;/forms&quot;,<br>      templateUrl: &quot;partials/forms.html&quot;,<br>      controller: &quot;FormsListCtrl&quot;,<br>      authenticate: true<br>    })<br>    .state(&quot;login&quot;, {<br>      url: &quot;/login&quot;,<br>      templateUrl: &quot;partials/login.html&quot;,<br>      controller: &quot;LoginCtrl&quot;,<br>      authenticate: false<br>    });<br>  // Send to login if the URL was not found<br>  $urlRouterProvider.otherwise(&quot;/login&quot;);<br>});</pre><p>Then, within my run function, I’m listening to the $stateChangeStart event, which fires each time you move within your application. It’s perfect for checking authentication.</p><p>You could wrap the following code into a directive to keep it clean, but for the sake of this article I’ve included it in the run event.</p><pre>angular.module(&quot;myApp&quot;)<br>  .run(function ($rootScope, $state, AuthService) {<br>    $rootScope.$on(&quot;$stateChangeStart&quot;, function(event, toState, toParams, fromState, fromParams){<br>      if (toState.authenticate &amp;&amp; !AuthService.isAuthenticated()){<br>        // User isn’t authenticated<br>        $state.transitionTo(&quot;login&quot;);<br>        event.preventDefault(); <br>      }<br>    });<br>  });</pre><p>The AuthService is just an example service, because as well as checking if the route requires authentication, you need to also check that they are actually authenticated. In my case I have a function that checks for the existence of their token, and ensures that it’s valid.</p><p>That’s it, pretty really simple huh! It’s so much easier to maintain compared to how I was handling this before, it keeps the authentication logic much cleaner, and I don’t have to include any authentication logic in my controllers, as this handles everything.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4e927af3a15f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>