How to tie angular-ui’s typeahead with a server via $http for server side optimization?

There is a way to implement this very easily, no need to roll out your custom solution (at least not for this case!). Basically you can use any function as part of the typeaheads expression, ex.: <input type=”text” ng-model=”selected” typeahead=”state for state in getStates($viewValue)”> As you can see from this example the getStates($viewValue) method (defined … Read more

How do I create an AngularJS UI bootstrap popover with HTML content?

UPDATE: As can been seen in this, you should now be able to do this without overriding the default template. ORIGINAL: As of angular 1.2+ ng-bind-html-unsafe has been removed. You should be using the $sce service Reference. Here is a filter for creating trusted HTML. MyApp.filter(‘unsafe’, [‘$sce’, function ($sce) { return function (val) { return … Read more

Angular-UI Router: Nested Views Not Working

I created working plunker here NOTE: You should read about state nesting and named views more. Because the current state and view definition is simply wrong. Nested States & Nested Views Multiple Named Views Firstly, we should not use the ONE state definition with many views: {}. But we should split them into real states. … Read more

Handle open/collapse events of Accordion in Angular

Accordion groups also allow for an accordion-heading directive instead of providing it as an attribute. You can use that and then wrap your header in another tag with an ng-click. <accordion-group ng-repeat=”group in groups” heading=”{{group.title}}” is-open=”group.open”> <accordion-heading> <span ng-click=”opened(group, $index)”>{{group.content}}</span> </accordion-heading> </accordion-group> Example: http://plnkr.co/edit/B3LC1X?p=preview

UI-router interfers with $httpbackend unit test, angular js

Take this gist https://gist.github.com/wilsonwc/8358542 angular.module(‘stateMock’,[]); angular.module(‘stateMock’).service(“$state”, function($q){ this.expectedTransitions = []; this.transitionTo = function(stateName){ if(this.expectedTransitions.length > 0){ var expectedState = this.expectedTransitions.shift(); if(expectedState !== stateName){ throw Error(“Expected transition to state: ” + expectedState + ” but transitioned to ” + stateName ); } }else{ throw Error(“No more transitions were expected! Tried to transition to “+ stateName ); … Read more

angularjs share data config between controllers

Consider the method described by this post: Extending AngularJS Controllers Using the Mixin Pattern Instead of copying your methods out of a service, create a base controller that contains those methods, and then call extend on your derived controllers to mix them in. The example from the post: function AnimalController($scope, vocalization, color, runSpeed) { var … Read more

Dynamically set the value of ui-sref Angularjs

Looks like this is possible to do after all. A breadcrumb on GitHub by one of the ui-router authors led me to try the following: <a ng-href=”https://stackoverflow.com/questions/24349731/{{getLinkUrl()}}”>Dynamic Link</a> Then, in your controller: $scope.getLinkUrl = function(){ return $state.href(‘state-name’, {someParam: $scope.someValue}); }; Turns out, this works like a charm w/ changing scoped values and all. You can … Read more

Enable angular-ui tooltip on custom events

Here’s a trick. Twitter Bootstrap tooltips (that Angular-UI relies upon) have an option to specify the trigger event with an additional attribute as in data-trigger=”mouseenter”. This gives you a way of changing the trigger programmatically (with Angular): <input ng-model=”user.username” name=”username” tooltip=”Some text” tooltip-trigger=”{{{true: ‘mouseenter’, false: ‘never’}[myForm.username.$invalid]}}” /> So when username is $invalid, the tooltip-triggerexpression will … Read more