How do I pass multiple attributes into an Angular.js attribute directive?

The directive can access any attribute that is defined on the same element, even if the directive itself is not the element. Template: <div example-directive example-number=”99″ example-function=”exampleCallback()”></div> Directive: app.directive(‘exampleDirective ‘, function () { return { restrict: ‘A’, // ‘A’ is the default, so you could remove this line scope: { callback : ‘&exampleFunction’, }, link: … Read more

Understanding AngularJS ng-src

Put the whole path inside the $scope variable. That way ng-src will wait until you provide it with the fully resolved path to the image: <div ng-controller=”MyCtrl”> <img ng-src=”https://stackoverflow.com/questions/18235169/{{ path }}” /> </div> function MyCtrl($scope, $timeout) { var path=”https://si0.twimg.com/profile_images/”; $timeout(function () { $scope.path = path + ‘2149314222/square.png’; }, 1000); }; FIDDLE

Angularjs autocomplete from $http

I made an autocomplete directive and uploaded it to GitHub. It should also be able to handle data from an HTTP-Request. Here’s the demo: http://justgoscha.github.io/allmighty-autocomplete/ And here the documentation and repository: https://github.com/JustGoscha/allmighty-autocomplete So basically you have to return a promise when you want to get data from an HTTP request, that gets resolved when the … Read more

Angular JS resizable div directive

This question is old, but for anybody looking for a solution, I built a simple directive to handle this, for vertical and horizontal resizers. Take a look at the Plunker angular.module(‘mc.resizer’, []).directive(‘resizer’, function($document) { return function($scope, $element, $attrs) { $element.on(‘mousedown’, function(event) { event.preventDefault(); $document.on(‘mousemove’, mousemove); $document.on(‘mouseup’, mouseup); }); function mousemove(event) { if ($attrs.resizer == ‘vertical’) … Read more

Getting “type or namespace name could not be found” but everything seems ok?

This can be the result of a .Net framework version incompatibility between two projects. It can happen in two ways: a client profile project referencing a full framework project; or an older framework version targeting a newer framework version For example it will happen when an application is set to target the .Net 4 Client … Read more

Update Angular model after setting input value with jQuery

ngModel listens for “input” event, so to “fix” your code you’d need to trigger that event after setting the value: $(‘button’).click(function(){ var input = $(‘input’); input.val(‘xxx’); input.trigger(‘input’); // Use for Chrome/Firefox/Edge input.trigger(‘change’); // Use for Chrome/Firefox/Edge + IE11 }); For the explanation of this particular behaviour check out this answer that I gave a while … Read more