angularjs-directive

AngularJS: Directive isolate scope - scope variable undefined

不打扰是莪最后的温柔 提交于 2019-12-23 18:53:43
问题 Please, can someone explain me, why attrDir 's scope variable is visible, and oneWay 's not? I thought that scope: {} is isolated as well. angular.module('test', []); angular.module('test').directive('attrDir', attrDir); function attrDir(){ return { scope: true, link: function(scope){ scope.hello = 'attrDir'; } }; } angular.module('test').directive('oneWay', oneWay); function oneWay(){ return { scope: { data: '<?' }, link: function(scope){ scope.hello = 'oneWay'; } }; } hello will be rendered

Directive not called on input change

孤者浪人 提交于 2019-12-23 18:49:14
问题 I'm facing an issue which I can't seem to solve. I have several inputs with each a directive to validate the input value, like this: <div class="row form-group"> <div class="col-sm-6">last name</div> <div class="col-sm-6"> <div class="input-group" ng-class="{'has-error': form.lastname.$invalid && (form.lastname.$touched || form.$submitted)}"> <input type="text" name="lastname" class="form-control" model-blur validator-lastname ng-trim="true" ng-model="fields.lastname.value" ng-maxlength=

Directive : $observe, class attribute change caught only once

瘦欲@ 提交于 2019-12-23 18:32:32
问题 I have a directive changing the style of a div and would like to be notified by $observe each time the class of the element changes. The problem is that it happens at directive creation but not after. Here is the code and a fiddle <div ng-app="testObserve"> <div ng-controller="Ctrl2"> <span class="rouge" ng-click="toggleClass()" my-test>Coucou</span> </div> </div> angular.module('testObserve', []) .controller('Ctrl2', function ($scope) {}) .directive('myTest', function () { function link

How to fix unexpected arguments passing from a function being on ng-change for select list?

我怕爱的太早我们不能终老 提交于 2019-12-23 18:01:18
问题 http://plnkr.co/edit/fFSoLmPFDBfNc2oOczZr?p=preview Directive code .directive('inputSelect', function() { return { templateUrl: 'someTemplate.html', restrict: 'E', scope: { ngModel: '=', ngChange: '&', options: '=' } }; }) Controller code $scope.someFunction = function(name) { console.log(name) }; $scope.colors = [{ name: 'black', shade: 'dark' }, { name: 'white', shade: 'light', notAnOption: true }, { name: 'red', shade: 'dark' }]; Template code <select ng-model="ngModel" ng-change="ngChange

Directive doesn't fire after changing textarea model

£可爱£侵袭症+ 提交于 2019-12-23 17:43:54
问题 I have a text with newline separator and URLs: first row\nFind me at http://www.example.com and also\n at http://stackoverflow.com . I want to update ng-repeat values after pressing on copy button. I have this HTML: <div ng-controller="myCntrl"> <textarea ng-model="copy_note_value"></textarea> <button data-ng-click="copy()">copy</button> <div> <p ng-repeat="row in note_value.split('\n') track by $index" wm-urlify="row" style="display: inline-block;" > </p> </div> </div> Controller: app

Directive In ionicModal complies first, before even controller loaded

房东的猫 提交于 2019-12-23 17:18:14
问题 I have a $ionicModal and inside that I have a directive, lets call it <scrap-link-cards> , this takes in the a two way data bind value of a scope object. This is inside a $ionicModal template:--> <scrap-link-cards datasource=(updates.update_links)> </scrap-link-cards> This is my full directive: .directive('scrapLinkCards', function ($log) { var controller = function ($scope) { $scope.links = angular.copy($scope.datasource); //undefined $scope.LastIndex = $scope.links.length - 1; }; var

Being wrapped by a directive, how can I access its scope?

只愿长相守 提交于 2019-12-23 17:02:07
问题 How can I access the directive's isolate scope in the directive's body? My DOM looks like this: <div ng-app="app"> <directive> <p>boolProperty: {{boolProperty|json}}</p> </directive> </div> The boolProperty is assigned inside the directive's link function: angular.module("app", []).directive("directive", function() { return { scope: {}, link: function($scope) { $scope.boolProperty = true; } }; }); The problem is, the child <p> inside the directive binds to the directive's parent scope, not

Using external Javascript files inside an Angular directive template

瘦欲@ 提交于 2019-12-23 17:01:18
问题 I am loading dinamically in my webapp "components", which has a directive, and a template, like the following: angular.module('app') .directive('carousel', function() { return { restrict: 'E', scope: { left: '@', top: '@' }, templateUrl: 'carousel.html' }; }); This template can have CSS dependencies, and it will work, but it won't work with Javascript. How do you think it could work? Template example (carousel.html) <link rel="stylesheet" type="text/css" href="example.css" media="all"> //This

(angularjs-google-maps) ng-click inside marker

只谈情不闲聊 提交于 2019-12-23 16:14:24
问题 This question is about angularjs-google-maps , https://github.com/allenhwkim/angularjs-google-maps Is there a way to use ng-click on a marker to set a variable like this? (the value of 1 is hard-coded for testing purposes). Clicking the marker currently does not seem to trigger the ng-click. <marker ng-repeat="instance in common.instances" position="[{{instance.lat}},{{instance.lng}}]" ng-click="common.selectedinstance = 1"> </marker> 回答1: From their document, https://developers.google.com

Angular doesn't work in IE 8, can't create a custom element for my directives

隐身守侯 提交于 2019-12-23 16:11:37
问题 I built my application from scratch for the past few weeks. I did it while implementing the instructions here. I have to say that everything works great with any normal browser such as Mozilla or Chrome, and the Angular.js framework has been of much use to me. The problem is that with IE8, everything seems to be broken, and the document.createElement DOM object throws an errro when I try to create an element for my custome directive(which I'm also using an 'x-' prefix for, as required by this