angularjs-directive

ng-repeat code getting commented out when viewed from browser

ぃ、小莉子 提交于 2019-12-05 02:03:44
问题 I see during load that the scope element $scope.docDetails has the necessary data. In the view when I use the ng-repeat to print info, I see that it is not displayed in browser. <body ng-controller="documentUploadController" nv-file-drop="" uploader="uploader" filters="queueLimit, customFilter"> <div class="container"> <div ng-repeat="row in documentUploadController.docDetails"> <div class="col-sm-2">{{row.DocumentTypeName}}</div> <div class="col-sm-3 elementwrap"><a href="#" ng-click=

How to create a directive for disable all elements into div element

感情迁移 提交于 2019-12-05 02:00:23
问题 how to create a directive for disable all elements into div element ? something like this : <div div-disabled div-disabled-condition="state=='Stack'||state=='Over'||state=='Flow'"> <input type="text"/> <input type="url"/> <div> <input type="text"/> <input type="url"/> </div> <div> Is it possible? I have no idea . angular .module('uiRouterApp.ctrl.add', ['uiRouterApp.ctrl.customDirective']) .controller('addCtrl', [ '$scope', '$location', '$stateParams', '$state', function ($scope, $location,

How to test a directive's controller using angularJS-karma-jasmine?

随声附和 提交于 2019-12-05 01:40:30
问题 Goal: Write a passing test for the waCarousel directive scope variable: self.awesomeThings . Expect this test pass when self.awsomeThings.length.toBe(3) to is true? Question: How can I properly write this test? rather how do I inject a directives controller? Directive: angular.module('carouselApp') .directive('waCarousel', function() { return { templateUrl: '../../../views/carousel/wa.carousel.html', controller: function($scope) { var self = this; self.awesomeThings = [1, 2, 3]; return $scope

Ng show if the variable is a number

我们两清 提交于 2019-12-05 01:33:39
I want to display an element only if a value is a number. How to do this? I tried : ng-show='angular.isNumber(10)' ng-show='isNumber(10)' Add to your scope: $scope.isNumber = angular.isNumber; and then use: ng-show="isNumber(10)" http://jsfiddle.net/88wqe/ eddiec <div ng-controller="Ctrl" ng-show="isNumber(num)"> AAA </div> function Ctrl($scope){ $scope.num = '10'; $scope.isNumber= function (n) { return !isNaN(parseFloat(n)) && isFinite(n); } } Here's a JS Fiddle http://jsfiddle.net/7RD47/ It uses the top answer from Validate decimal numbers in JavaScript - IsNumeric() , which is a more

ng-change event only fires once for each radio button when created with ng-repeat

和自甴很熟 提交于 2019-12-05 01:12:07
I have created an AngularJS directive with radio buttons to control which environment my page will query against and added it to my page. I am using a two-way binding to map a local scope variable called environment to an app variable with the same name. It seems to work well when I create the radio buttons explicitly in the template (in my actual code I'm using templateUrl instead, but still have the same problem). <div> <label><input type="radio" name="env" ng-model="environment" ng-change="changeEnvironment(1)" value="1" />Testing</label> <label><input type="radio" name="env" ng-model=

Passing arguments to ngChange event call from inside directive

℡╲_俬逩灬. 提交于 2019-12-04 23:45:04
I have a directive that accepts an ng-change attribute: <radio-buttons options="optionsList" ng-model="myModel" ng-change="myCallback($event)"></radio-buttons> I've defined a function in my controller, myCallback , that looks like this: $scope.myCallback = function(e) { console.log("Callback from controller"); console.log(e); } The following function select exists within my radioButton directive. I need to define when the ngChange callback is executed inside my directive in the select function: function select(scope, val) { if (!scope.disabled && scope.selectedValue != val) { scope

Render AngularJS directive on $http loaded content

坚强是说给别人听的谎言 提交于 2019-12-04 23:26:54
I have a bit of a problem. I have a directive app.directive('a', function() { return { restrict: 'E', link: function(scope, elem, attrs) { elem.on('click', function(e){ e.preventDefault(); alert('Hyperlinks not allowed!'); }); } }; }); and a $http request for JSON containing the page content { "currentNodeName":"Page 1", "childrenNodes":[ {"id":"3","name":"Page 1-1"}, {"id":"4","name":"Page 1-2"}], "parentNode":null, "currentNodeContent":[ {"content":"<p>This is Page1. <a href=\"http://badlink.org/i/dont/want/to/work\">Link</a></p>"}], "currentNodeId":"1" } The currentNodeContent is loaded to

Display AngularStrap Dropdown Manually - How?

萝らか妹 提交于 2019-12-04 23:19:47
I am trying to display an AngularStrap dropdown manually, leveraging the trigger configuration on $dropdownProvider as such // how dropdown is triggered - click | hover | focus | manual app.config(function($dropdownProvider) { angular.extend($dropdownProvider.defaults, { trigger: 'manual' }); }); click hover focus all work fine, but why not manual ? I have yet to discover any proof that this offered api configuration option works. How can I do this? In fact, this issue seems to have been discovered after my original question positing, but is now closed and over a year later I have yet to find

How to get ng-model value inside custom directive

余生长醉 提交于 2019-12-04 23:12:10
I've searched here on SO and tried the answers I found, but I can't seem to get the model value out of the ngModel of my custom directive. Here's the directive /* *usage: <markdown ng:model="someModel.content"></markdown> */ breathingRoom.directive('markdown', function () { var nextId = 0; return { require: 'ngModel', replace: true, restrict: 'E', template: '<div class="pagedown-bootstrap-editor"></div>', link:function (scope, element, attrs, ngModel) { var editorUniqueId = nextId++; element.html($('<div>' + '<div class="wmd-panel">' + '<div id="wmd-button-bar-' + editorUniqueId + '"></div>' +

Call jquery plugin in directive only after data is renderer in DOM

ε祈祈猫儿з 提交于 2019-12-04 23:08:44
I want to initialize a jquery plugin in an angular directive but only after the service data is returned and first renderer in the DOM. I can seem to figure out how to do this in angular directive. I have this code so far, but it seems that i am calling the plugin after the service data arrived, but before it is renderer on the DOM... Any hints? myApp.directive('myDirective', function () { return { restrict: 'A', link: function ($scope, element, attrs) { $scope.$watch("data.length", function( newValue, oldValue ) { if ( newValue === oldValue ) { console.log( "Should return..." ); return; } $