How to use angular2 built-in date pipe in services and directives script files [duplicate]

Since CommonModule does not export it as a provider you’ll have to do it yourself. This is not very complicated. 1) Import DatePipe: import { DatePipe } from ‘@angular/common’; 2) Include DatePipe in your module’s providers: NgModule({ providers: [DatePipe] }) export class AppModule { } or component’s providers: @Component({ selector: ‘home’, styleUrls: [‘./home.component.css’], templateUrl: ‘./home.component.html’, … Read more

How can I simulate a click event in my AngularJS directive test?

You can use triggerHandler, part of JQLite. I used this to trigger a click event on a directive… element = angular.element(“<div myDirective-on=’click’></div>”); compiled = $compile(element)($rootScope); compiled.triggerHandler(‘click’); Full example available on this blog post: http://sravi-kiran.blogspot.co.nz/2013/12/TriggeringEventsInAngularJsDirectiveTests.html

angular trigger changes with $watch vs ng-change, ng-checked, etc

Both $watch and ngChange have totally different usages: Lets say you have a model defined on a scope: $scope.myModel = [ { “foo”:”bar” } ]; Now if you want to do something whenever any changes happen to myModel you would use $watch: $scope.$watch(“myModel”, function(newValue, oldValue){ // do something }); ngChange is a directive that would … Read more

Using $compile on external template (templateURL) in Angular directive

You can use the $templateRequest service to get the template. This is a convenience service that also caches the template in $templateCache, so that only a single request to template.html is made. As an illustration (and without going into the issue of recursive directives), this is used like so: link: function(scope, element){ $templateRequest(“template.html”).then(function(html){ var template … Read more

How do you mock directives to enable unit testing of higher level directive?

Directives are just factories, so the best way to do this is to mock the factory of the directive in using the module function, typically in the beforeEach block. Assuming you have a directive named do-something used by a directive called do-something-else you’d mock it as such: beforeEach(module(‘yourapp/test’, function($provide){ $provide.factory(‘doSomethingDirective’, function(){ return {}; }); })); … Read more

How to create an angularJs wrapper directive for a ui-bootstrap datepicker?

To be honest, I’m not quite sure why it’s caused and what’s causing your date to be “toString-ed” before showing it in the input. However, I did find places to restructure your directive, and remove much unnecessary code, such as $compile service, attributes changes, scope inheritance, require in the directive, etc.. I used isolated scope, … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)