Search Posts

Category: angularjs-directive

Angularjs failed to load templateurl

here is the directive moduleDirectives .directive(‘barNotification’, [‘$compile’, ‘$timeout’, function ($compile, $timeout) { return { restrict: ‘E’, replace: true, scope: { barShow:’=’, barType: ‘=’, barMessage:’=’, barAllowClose:’=’, onClose: ‘&’, onOpenSlopeSetting: ‘&’ }, link: function (scope, element, attr) { scope.contentElement = element; scope.onCloseExists = ‘onCloser’ in attr; scope.$watch(‘barMessage’, function () { $timeout( function () { angular.element(scope.contentElement[0].querySelector(‘#barMessage’)).replaceWith($compile(‘<div id=”barMessage”>’ + scope.barMessage + ‘</div>’)(scope)); }); }, true); }, templateUrl: ‘/Areas/Claim/Singlepage/directives/barnotification/barNotification.cshtml’, controller: ‘barNotificationController’ }; }]); Here is the project directory When the […]

Uncaught Error: Unknown provider: $filterProvider from myapp

I am getting following error: ( Uncaught Error: Unknown provider: $filterProvider from myapp) while using following code. Please help to solve it. Uncaught Error: Unknown provider: $filterProvider from myapp at angular.min.js:29 HTML——————— <script src=”http://ajax.googleapis.com/ajax/libs/angularjs/1.0.6/angular.min.js”>`</script> <div ng-app=”myapp” ng-controller=”WeatherCtrl”> <h2>Weather in Salzburg, Austria</h2> <weather-icon cloudiness=”{{ weather.clouds }}”></weather-icon> <h3>Current: {{ weather.temp.current | temp:2 }}</h3> min: {{ weather.temp.min | temp }}, max: {{ weather.temp.max | temp }} </div> Source code (.js)——————- ‘use strict’; var myapp = angular.module(‘myapp’, []); myapp.factory(‘weatherService’, […]

How to add an Angular expression (double curly braces) dynamically from a directive

I’m trying to add a custom attr. to an Html element with an Angular expression inside the directive’s compile function. However i can’t wrote the double curly braces because the ‘elem.attr()’ function deletes them. Any idea? Thanks in advance! function sbiLoading($compile, $timeout) { return { restrict: ‘A’, scope: {}, controller: function($scope) {}, compile: function(tElem, tAttrs) { return { pre: function(scope, iElem, iAttrs) { iElem.removeAttr(‘sbi-loading’); iElem.attr(‘loading-data’, ‘{{loadingData}}’); iElem.attr(‘class’, ‘loaded-main-wrapper’); var compiledElement = $compile(iElem)(scope); iElem.replaceWith(compiledElement); } }; […]

How to bind selected option value in ng-options to a value of object in the controller?

I have some troubles while trying to update the current selected value of an option in ng-options.I have an array which contains one object. The object has ‘value’ and ‘name’ properties whose values are constant. I am using this constant array in a custom directive with select and ng-options. This is part of the directive’s html: <select name=”{{vm.name}}” ng-model=”vm.model” ng-options=”arrayObject.value as arrayObject.name for arrayObject in vm.constantArrayofObject”> </select> And I use this directive in a form […]