directive

Controller 'ngModel', required by directive '…', can't be found

守給你的承諾、 提交于 2019-11-29 03:27:32
What's going on here? Here are my directives: // template <input ng-model="theModel" /> app.directive('bseInput', function () { return { templateUrl: "/Scripts/bse/bse-inputs.html", scope: { theModel: '=', }, compile: function compile(tElement, tAttrs, transclude) { // do stuff } }; }); app.directive('submitRequired', function (objSvc) { return { require: 'ngModel', link: function (scope, elm, attrs, ctrl) { // do something } }; }); Here is an example of the directive in use: <input bse-input submit-required="true" the-model="someModel"></input> Here is the actual error text: Error: [$compile

AngularJS - Formatting ng-model before template is rendered in custom directive

一笑奈何 提交于 2019-11-29 02:53:24
问题 I am creating a custom directive in Angular JS. And I want to format the ng-model before the template renders. This is what I have so far: app.js app.directive('editInPlace', function() { return { require: 'ngModel', restrict: 'E', scope: { ngModel: '=' }, template: '<input type="text" ng-model="ngModel" my-date-picker disabled>' }; }); html <edit-in-place ng-model="unformattedDate"></edit-in-place> I want to format the unformattedDate value before it is entered in the ngModel of the template

How to get FormControl instance from ControlValueAccessor

不打扰是莪最后的温柔 提交于 2019-11-29 02:42:54
问题 I've the following component: @Component({ selector: 'pc-radio-button', templateUrl: './radio-button.component.html', providers: [ {provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => FieldRadioButtonComponent), multi: true} ] }) export class RadioButtonComponent implements ControlValueAccessor { ... } I can assign and alter the value through these inputs: <pc-radio-button [formControl]="formControl"></pc-radio-button> <pc-radio-button [formControlName]="inputControlName"></pc-radio

Angular directive with ng-repeat, ng-show “Show more” and lazy-load

我怕爱的太早我们不能终老 提交于 2019-11-28 23:39:28
I use this directive, iterating over an array "myArr", filtering for a few conditions. <myDirective myData='item' ng-repeat="item in filteredArr = (myArr | filter:searchField | filter:checkboxFilter)" ng-show="$index < visible" /> This gives me two issues I'd like to get some input on: a) the ng-show part is there because I have a condition that handles this: <p> <a ng-click='visible=visible+10' ng-show='visible < filteredArr.length'>Show more</a> </p> in order to show or hide the "Show more" part. I cannot come up with another idea on toggling this and/or the items itself. $scope.visible is,

Attribute directive with ngModel to change field value

大兔子大兔子 提交于 2019-11-28 17:05:48
I want to change (force) input field values while typing using a attribute Directive. With it I would like to create directives like uppercase, lowercase, maxlength, filterchar, etc. to be used on input fields on forms. I found this example: Angular 2 Attribute Directive Typescript Example but this doesn't seem to work. Maybe it did for an earlier build of Angular2. It is however exactly what I would like to do. When I create a directive like this: import {Directive} from 'angular2/core'; import {NgModel} from 'angular2/common'; @Directive({ selector: '[ngModel][uppercase]', host: { '(input)'

Define AngularJS directive using TypeScript and $inject mechanism

倖福魔咒の 提交于 2019-11-28 15:47:51
Recently I started refactoring one of the Angular projects I am working on with TypeScript. Using TypeScript classes to define controllers is very convenient and works well with minified JavaScript files thanks to static $inject Array<string> property. And you get pretty clean code without splitting Angular dependencies from the class definition: module app { 'use strict'; export class AppCtrl { static $inject: Array < string > = ['$scope']; constructor(private $scope) { ... } } angular.module('myApp', []) .controller('AppCtrl', AppCtrl); } Right now I am searching for solution to handle

Controller 'ngModel', required by directive '…', can't be found

对着背影说爱祢 提交于 2019-11-28 09:34:39
What's going on here? Here is my directive: app.directive('submitRequired', function (objSvc) { return { require: 'ngModel', link: function (scope, elm, attrs, ctrl) { // do something } }; }); Here is an example of the directive in use: <input submit-required="true"></input> Here is the actual error text: Error: [$compile:ctreq] Controller 'ngModel', required by directive 'submitRequired', can't be found! http://errors.angularjs.org/1.2.2/$compile/ctreq?p0=ngModel&p1=submitRequired at http://www.domain.ca/Scripts/angular/angular.js:78:12 at getControllers (http://www.domain.ca/Scripts/angular

How do I access the directive instance in angular from console?

萝らか妹 提交于 2019-11-28 04:49:37
问题 ng.probe($0).componentInstance -- will give the reference to the instance. Is there any way to access the directive instance from the console? 回答1: Directive instance doesn't differ from other providers in this respect, it can be retrieved from injector. In order to retrieve provider instance, it is necessary to have provider token, which is directive class. Since application classes aren't exposed to global scope, debug element providerTokens can be inspected. Given the application is

PHP log will not ignore repeated errors with ignore_repeated_errors = On

微笑、不失礼 提交于 2019-11-28 04:48:03
问题 Although I have instructed php to only log an error once - i see the error over and over again in my log file. Any ideas why this directive would get ignored? I've restarted apache, etc. 回答1: This directive will only stop the error from being logged again within the same script run . When the same script is run multiple times, you will still see that error every time. 回答2: Besides the ignore_repeated_errors , there is also the ignore_repeated_source ini settings. I think that one would work

Angularjs - Pass argument to directive

冷暖自知 提交于 2019-11-28 04:16:56
Im wondering if there is a way to pass an argument to a directive? What I want to do is append a directive from the controller like this: $scope.title = "title"; $scope.title2 = "title2"; angular.element(document.getElementById('wrapper')).append('<directive_name></directive_name>'); Is it possible to pass an argument at the same time so the content of my directive template could be linked to one scope or another? here is the directive: app.directive("directive_name", function(){ return { restrict:'E', transclude:true, template:'<div class="title"><h2>{{title}}</h3></div>', replace:true }; })