angularjs-directive

ng-model changes of type in radio button

眉间皱痕 提交于 2019-12-23 09:40:35
问题 Please note this example: JSFiddle Sample <div ng-controller="myCtrl"> var ng-model = {{myValue}} - {{myType}} <input type="radio" value="true" name="boolean" ng-change="logIt()" ng-model="myValue" /> True <input type="radio" value="false" name="boolean" ng-change="logIt()" ng-model="myValue" /> False </div> var myApp = angular.module('myApp',[]); function myCtrl($scope) { $scope.myValue = true; //does not work //$scope.myValue = 'true'; //it does work $scope.myType =(typeof $scope.myValue);

Angularjs pass multiple arguments to directive ng-repeat

烈酒焚心 提交于 2019-12-23 09:34:28
问题 I am stuck in a doubt I have html : Here, there are two types of data : post and person. The json for each post has array of persons. I wish to retrieve the rating Value, dataCategory and id (mydata.id/childData.id) from directive to controller : <div ng-repeat="mydata in data" class="ng-scope ng-binding"> <p class="ng-binding">{{mydata.postdata}}</p> <div star-rating rating-value="rating" data-cat="post" data-id="{{mydata.id}}" ></div> <div ng-repeat="childData in mydata.personRelatedData">

How to create Dynamic factory in Angular js?

狂风中的少年 提交于 2019-12-23 09:33:47
问题 In my project i have to create dynamic factory in angular js with dynamic factory name like below function createDynamicFactory(modId) { return myModule.factory(modId + '-existingService', function (existingService) { return existingService(modId); }); } I want to get new factory with dynamic name , when i called this function. unfortunately this is not working. how can i achieve this? and how to inject in my controller or in directive dynamically? 回答1: You can annotate your service generator

Testing directives that uses templates

那年仲夏 提交于 2019-12-23 09:28:12
问题 How can i unit test directives that use templateUrl to load templates? Since $httpBackend is a mock, it will not load templates either. I would like to be able to use something like $httpBackend.whenGET(/^\/views\//).passThrough(); and let it actually get the templates, but I haven't figured out how to do this correctly. I think I have something confused regarding how to unit test directives. Disclaimer: I have no experience testing, or using jasmine nor testacular. Any help is appreciated.

Using ngOptions inside directive

若如初见. 提交于 2019-12-23 09:26:56
问题 I have the following shuttle boxes directive: <shuttle-boxes ng-options="item for item in itemList" ng-model="myModel" /> My template looks like this: template: '<div class="shuttle-boxes">' + '<select multiple="multiple" class="shuttle-boxes-left"></select>' + '<button class="shuttle-boxes-btn" type="button"><i class="icon icon-arrow-right"></i></button>' + '<button class="shuttle-boxes-btn" type="button"><i class="icon icon-arrow-left"></i></button>' + '<select multiple="multiple" class=

isolateScope() returning undefined when testing angular directive

谁都会走 提交于 2019-12-23 08:03:15
问题 Using Angular v1.2.25 and rails asset pipeline, I am attempting to test that a directive's isolate scope has indeed been updated. Since isolateScope() returns undefined I am getting expected undefined to be defined ...' describe("cool directive", function() { beforeEach(module('necessaryModule')); var scope, $rootScope, $compile, elem, baseElement = '<div auto="mock_a" inc="mock_p" method="mock_m" reset-method="mock_r"></div>'; beforeEach(inject(function( _$rootScope_, _$compile_, _

AngularJS ng-drag

自作多情 提交于 2019-12-23 07:55:46
问题 I'm new to AngularJS and I have a bit pressure on the current project that's why I'm asking here. I see that AngularJS has ng-dragstart event (http://docs.ng.dart.ant.c-k.me/angular.directive/NgEventDirective.html) but it doesn't seem to work. On other pages I can see that other developers recommend to do new 'directives'. So my question is: "Is there a native ng-drag functinallity implemented within AngularJS or should I implementi by myself?" 回答1: You'll need to implement it yourself if you

angularjs: setting focus on a previously-hidden input element inside a directive

拥有回忆 提交于 2019-12-23 07:05:34
问题 Here is a simplified plunk to illustrate the problem I got an angular directive that compiles some html code before visualizing it. In the html, there is an hiden input that becomes visible only if scope.isEditShown is true : <input ng-show='isEditShown' type='text' value='{{content.name}}' class='title_edit'/> The input appears when the scope.titleChange function is invoked. This function (bound to an ng-dblclick directive) just sets true to scope.isEditShown and tries to invoke jQuery's

angularjs 1.5 component dependency injection

好久不见. 提交于 2019-12-23 06:44:06
问题 this may sound newb, but I have been following this tutorial for angularjs component. I am new to components and how do I inject a constant Utils or authService to my component like this? app.component('tlOverallHeader', { bindings: { data: '=' }, templateUrl: 'js/indexTimeline/components/tl_overallHeader/templates/tl_overallHeader.html', controller: function() { this.ms = 'tlOverallheader!' } }) thanks! 回答1: You should be able to inject services into your component's controller just like a

Why this is not loading view1.cshtml in MVC empty web application ANGULAR

北城余情 提交于 2019-12-23 06:13:06
问题 I am learning Angular. I am watching a 2 years old video, and I am trying to use route concept and using in view1.CShtml (Remember, its CShtml and not html, while in the video, he uses html). I also find it wierd that Views path starts as ~Views/View1.cshtml (Fair enough I have it in Views folder) on contrary to Partial/View1 where the video demonstrator has. Now, I do not understand what is this "~" for when I have similar directory structure like demonstrator. Also, sadly, the view1 is not