angularjs-directive

dynamically naming input controls in angularjs

心不动则不痛 提交于 2019-12-05 21:03:58
I have a input element which I am trying to name dynamically, but I had no luck so far using angular js. neither <input type="text" name="resource.Name" ng-model="resource.Value" ng-required="resource.IsRequired"> nor <input type="text" name="{{resource.Name}}" ng-model="resource.Value" ng-required="resource.IsRequired"> works for me. When I try to access name attribute it always comes back as resource.Name instead of the value it contains. The main reason I am trying to name this input control is validation, if user does not enter text in the field, I would like to tell them which textbox is

Submitting a form within Karma process => Some of your tests did a full page reload

青春壹個敷衍的年華 提交于 2019-12-05 20:45:49
In one angular directive, I have this code: $('[name=' + formName + ']').bind('submit', function () { validate(); }); In the beforeEach clause of a Karma test, I have this code: bootstrapInput = $compile('<form novalidate name="aForm">' + '<input-field icon="true" for="email">' + '<div>' + '<input class="form-control" class="email" name="email" id="email" type="email" ng-model="user.email" required />' + '</div>' + '<input-validation for="email" custom-error="custom error" required="Email is required" email="Email must be in valid format"/>' + '</input-field>' + '<button type="submit" value=

angularjs : @mention in textarea

杀马特。学长 韩版系。学妹 提交于 2019-12-05 20:39:18
问题 I want to display an autocomplete form triggered by the word @ in my textarea like this library http://ichord.github.io/At.js/ but only using angularjs & css What kind of directive should I write ? Also, is there a way to implement this with the angular bootstrap UI typehead directive ? 回答1: See https://github.com/jeff-collins/ment.io for a directive that likely does what you are looking for. 回答2: I've written angular-otobox, a dependency-less angular directive for mentioning, tagging and

Why directive has scope?

心不动则不痛 提交于 2019-12-05 20:31:19
As far as I know that basically scope is an instance of a controller. Every time I declare a controller scope will be available for that controller. But then why directive has scope in link function ? I didn't declare any controller for the directive. Then why link function has scope ? Any Idea ? Bhojendra Rauniyar From the doc : scope: The scope to be used by the directive for registering watches . You may also be interested to see the differences between $scope and scope . All directives have a scope associated with them. They use this scope for accessing data/methods inside the template and

Angucomplete-alt: Remote-API-handler not working as expected

蓝咒 提交于 2019-12-05 20:23:46
I'm using angucomplete-alt ( https://github.com/ghiden/angucomplete-alt ) in an AngularJS project, however I can't seem to make it work. I'm trying to build a really simple autocomplete form, like this: <angucomplete-alt pause="400" selected-object="obj" remote-api-handler="search" title-field="id" minlength="1" /> And my function is defined in the controller as such: $scope.search= function (userInputString, timeoutPromise) { return $timeout(function () { return [{ "id": "1" }, { "id": "2" }, { "id": "3" }] }, 1000); However, everytime I try to search, I get "No results", even though the

angular + jasmine + mock $stateParams in a directive

烈酒焚心 提交于 2019-12-05 19:45:23
What is the best approach to mock $stateParams in a directive? $stateParam members will be changed according to the test. I can easily mock $stateParams in a controller using $controller('ctrl', $stateParams) but dont know how to modify $stateParams that gets injected into the directive. I've gone the route of decorating $stateParams with the below but can only declare that when i create the module. as i mentioned, $stateParam members will change many times through the different tests. beforeEach(angular.mock.module(function ($provide) { $provide.provider('$stateParams', function () { return {

Octal literals are not available when targeting ECMAScript 5 and higher

左心房为你撑大大i 提交于 2019-12-05 19:10:46
I am building a norwegaian SSN validator in angularjs and getting the error as 'Octal literals are not available when targeting ECMAScript 5 and higher.' but everything works fine in es3 mode ,please help me with the issue module ec.directives { export function norwegianSsnValidator(){ return { restrict: 'A', require: 'ngModel', link: function(scope, element, attrs, ctrl){ ctrl.$validators.invalidSSN = function(ssn:string){ if(typeof ssn !== "string"){ return false; } var pno = ssn, day, month, year, ind, c1, c2, yearno; // Check length if( pno.length != 11 ) return false; // Split day = pno

If 'ng-template' is a Web Component then add “CUSTOM_ELEMENTS_SCHEMA” to the of this component to suppress this message. (\"[ERROR ->]<ng-template>

丶灬走出姿态 提交于 2019-12-05 18:58:11
zone.js@0.6.25?main=browser:355 Unhandled Promise rejection: Template parse errors: 'ng-template' is not a known element: 1. If 'ng-template' is an Angular component, then verify that it is part of this module. 2. If 'ng-template' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas' of this component to suppress this message. ("[ERROR ->] ; Task: Promise.then ; Value: Error: Template parse errors: 'ng-template' is not a known element: I have applied this FIX in my App.module.ts: import { NgModule, CUSTOM_ELEMENTS_SCHEMA ,NO_ERRORS_SCHEMA} from '@angular/core';

How to add zoom in zoom out buttons in visjs using angularjs?

人走茶凉 提交于 2019-12-05 18:55:14
Need help in having a zoom in and zoom out button in visjs network graph using angularjs, I could not find any relevant options for this. Please help, I am also providing a plunker link as an example Code <vis-network data="data" options="options" height="100%"></vis-network> $scope.options = { autoResize: true, height: '800', width: '100%' }; Take a look at the interaction, navigationButtons option. It has built in controls for zoom, pan and reset view. You need to change your vis options to include navigationButtons: true and keyboard: true to have keboard shortcuts enabled $scope.options =

How to get access to a directive attrs with isolated scope?

给你一囗甜甜゛ 提交于 2019-12-05 18:30:34
I need to have access to model created by directive and in the same time I need to get attrs in the directive. JS: module.directive('createControl', function($compile, $timeout){ return { scope: { name: '=Name' // Dynamically created ng-model in the directive element }, link: function(scope, element, attrs){ attrs.$observe('createControl', function(){ attrs.createControl //is empty if scope is an object, otherwise it is passed from html attribute } } HTML: <div class="control-group" ng-repeat="x in selectedControls"> <div create-control="{{ x }}"></div> </div> If scope is defined as an object,