angularjs-directive

How do I test the HTML pointed to by the templateUrl of an angular directive?

99封情书 提交于 2019-12-10 21:22:28
问题 I have a directive: app/controllers/battle.js angular.module('myModule') .controller('myController', ['$scope', function($scope){ $scope.sayHello = function(){console.log('hello');}; }]) .directive('myDirective', function(){ return { templateUrl: '../views/testView.html' } }); That directive is called as follows: app/views/routeOne.html <my-directive ng-controller='myController'></my-directive> The directive templateUrl points to a file that looks like: app/views/testView.html <div id=

media player object from directive

廉价感情. 提交于 2019-12-10 20:58:18
问题 I'm trying to make accessible a flowplayer media player using a directive. so that parent controllers can broadcast events and then the player just responds to those events using listeners. the events are working but the player is undefined so not really working. my problems are: 1) player not initializing. - i must not be setting this up correctly. 2) I want the player object available in the scope as $scope.player so I can tell it to $scope.player.play() or $scope.player.stop(). something

AngularJS - How do I access the form defined inside a templateUrl in my directive?

大城市里の小女人 提交于 2019-12-10 20:53:00
问题 I am attempting to access the form inside my directive for validation purposes, so I'd like access to $setPristine, however, I can't seem to figure out how to get the form if it's created using a templateUrl. I have a plunker detailing the issue here: http://plnkr.co/edit/Sp53xzdTbYxL6DAue1uV?p=preview I'm getting an error: Controller 'form', required by directive 'testDirective', can't be found! Here is the relevant Plunker code: .js: var app = angular.module("myApp", []); app.directive(

AngularJS: minifications breaks my directive

拈花ヽ惹草 提交于 2019-12-10 20:26:22
问题 I use a directive to ask user for action confirmations in modals. It works like a charm during development, but, after minification, it's broken. This is the dreadful " $injector: unpr " error I get: Error: [$injector:unpr] Unknown provider: aProvider <- a ... I presume the problem is that $scope and $modalInstance are renamed, and should not be, but I don't know how to avoid this... This is the directive code: 'use strict'; app.directive('reallyClick', ['$modal', function($modal) { var

Data-binding in a directive template

不羁的心 提交于 2019-12-10 20:14:04
问题 I'm trying to build a really basic Angular directive that generates a "div" that can have two states: "on" and "off". I've naively come up with an implementation that you can find here: http://jsfiddle.net/wSz2f/ The initial display is correct but the visual state is not updated when the scope state changes. Here is the Angular directive definition: var test = angular.module("test", []); test.directive("led", function() { return { restrict: "E", replace: true, template: "<div class='led led

Angularjs with Internet Explorer 11, security issue

南楼画角 提交于 2019-12-10 20:03:12
问题 I'm using Angularjs for some months and it works like a charms in Chrome/Firefox/Safari but face some problems with IE11 and Edge. It seems my problem come from ng-src since images are not displayed and src attribute is never set. Here is the code: <div class="cell col-xs-12 col-sm-6 col-md-4 col-lg-3" ng-repeat="obj in DATA.objects | orderBy:objectsOrder track by $index "> <div ng-click="setCurrent($event, obj, '{{'obj_nav_' + $index}}')"> <img ng-src="{{formatURL(obj.Id, obj.img.fileName)}}

Unit Test Karma Jasmine SyntaxError: Parse error on “&” Angular Directive binding

≯℡__Kan透↙ 提交于 2019-12-10 19:25:00
问题 I get SyntaxError: Parse error at my directive line where I want to use a "&" one-way binding from a parent directive's method myApp.directive('datasourceDeleteBtn', [function() { return { restrict: 'E', replace: true, template: '<a href="#">&#x2715</a>', scope: { datasourceIndex: '@', removeParentDiv: '&' }, link: link }; function link(scope, element, attr) { element.bind('click', function(event) { event.preventDefault(); scope.deleteDatasource(scope.datasourceIndex); }); // Notify parent

Expose an object from an Angular service using Getter function return undefined

蹲街弑〆低调 提交于 2019-12-10 18:54:00
问题 here is the code: authServ.getUser() returns {} (an empty object, which corresponds to the declaration of this var), from everywhere, even after the revision that I have made to the return syntax according to this [question][1]. Can anyone please advise what is the issue?, I don't see a reason why it shouldn't work app.factory('authService', function($http){ var authServ = {}; var currentUser = {}; authServ.authUser = function(){ return $http.head('/users/me', {withCredentials: true}); },

why list is not display while using collection-repeat instead of ng-repeat

旧城冷巷雨未停 提交于 2019-12-10 18:42:11
问题 I used ng -repeat in my demo .But due to large data coming from service .I want to use collection-repeat for performance better .how I will use collection-repeat to get the same out put here .here is my plunker <ion-scroll scrollbar-y="true" delegate-handle="i" ng-style="viewHeight"> <div class="row" ng-repeat="column in i | limitTo: counter track by $index" ng-class-odd="'odd-row'"> <div class="col brd collapse-sm" ng-repeat="field in column.columns" ng-show="i[$index].checked && i[$index].f

uiGrid switch rows and columns

霸气de小男生 提交于 2019-12-10 18:28:11
问题 This is a bit of a general question into the possibilities of ui grid. I have had tremendous success with ui grid thus far. Now I have a use case where I want to switch the rows and columns of the grid. Basically, I would like the headers to be displayed 'vertically' in the first column and to have the rows become columns. Is this possible with ui grid? 回答1: As far as i know UI-grid doesn't support this. I doubt if you can do that. May be try building ColumnsDef and Data dynamically and pass