angularjs-directive

How to wait for asynchronous data before updating ui-options

谁说我不能喝 提交于 2019-12-24 11:29:31
问题 I'm trying to create a graph with ui-options like this: <div ui-jq="plot" ui-options=" [ { label: 'Strongly Agree', data: {{stronglyAgree}} }, { label: 'Agree', data: {{agree}} }, { label: 'Disagree', data: {{disagree}} }, { label: 'Strongly Disagree', data: {{stronglyDisagree}} }, { label: 'N/A', data: {{na}} } ] " style="height:240px"></div> But the data in double-curly brackets hasn't arrived yet, so it reads as empty and throws errors. This is inside a directive: function latestSurvey(){

Select directive not selecting option when options are loaded asynchronously

旧街凉风 提交于 2019-12-24 11:22:12
问题 I have a <select> directive whose options are loaded asynchronously. The variable that the ng-model attribute points to exists prior to the options being loaded. However, after the options are loaded the correct option is not selected. Instead, the select becomes blank. I've created a plunk to demonstrate this behaviour: http://plnkr.co/edit/KNunC6. 回答1: https://github.com/angular/angular.js/issues/9714#ref-pullrequest-53337829 seems like this is an angular core bug. you'd be more successful

Error: [$compile:multidir] for Component Directive with Attribute Directive

∥☆過路亽.° 提交于 2019-12-24 10:57:59
问题 I need a 'sticky' directive that adds a css class to element when it is at the top of a page and also signals the changes in its state. For that reason I define a scope like { onStickyChange: '&' } . Now I'd like to use the directive in an angularjs component like: <my-component sticky on-sticky-change="$ctrl.onStickyChange(sticky)"> </my-component> I expected the directive to notify the parent controller when the my-component is sticked/unsticked. However I get the following error: Error: [

nginclude add / to the main url

孤街醉人 提交于 2019-12-24 10:50:32
问题 Any idea why this is happening? I try to use ng-include="'html_template'" URL Result WITH ng-include http://localhost/app/grid#/leave URL Result WITHOUT ng-include http://localhost/app/grid#leave Notice that the forward slash "/" is added. 回答1: Actually there is question and answer about that Preserve traditional anchor behavior with ng-include In summary of that answer, ng-include requires $anchorScroll, and $anchorScroll requires $location. As long as $location is involved, it changes the

How to catch an event trigger inside of a <ng-container>

非 Y 不嫁゛ 提交于 2019-12-24 10:48:33
问题 Good afternoon guys, i have the following structure: parent.html <child-component> <ng-template let-dataSource="dataSource" let-displayedColumns="dc"> <mat-table class="cruds-table" [dataSource]="dataSource" matSort fusePerfectScrollbar> <ng-container matColumnDef="name"> <mat-header-cell *matHeaderCellDef mat-sort-header>Nome</mat-header-cell> <mat-cell *matCellDef="let crud"> <p class="text-truncate" (click)="clica()">{{crud.name}}</p> </mat-cell> </ng-container> [...]</ng-template> </child

Angular directive for route provider

吃可爱长大的小学妹 提交于 2019-12-24 10:45:34
问题 The angular tutorial invokes the route provider explicitly below, (being adapted for the sake of succinctness) angular.module('myApp', []). config(['$routeProvider', function($routeProvider) { $routeProvider. when('/myResource1', {templateUrl: 'partials/myView1.html', controller: MyController1}). when('/myResource2', {templateUrl: 'partials/myView2.html', controller: MyController2}). otherwise({redirectTo: '/index.html'}); }]); Can we define the route provider separately , then invoke it by

Angular $watch does not fire any event in my directive

别等时光非礼了梦想. 提交于 2019-12-24 10:44:47
问题 i try to update an elements content depending on the attribute value of my custom directive. the code below performs well but only once on site-load. dynamic updates on the attribute value do not fire any event. what do i do wrong? markup inside ng-repeat (match in matches): <div ng-tipp-result="[[getIconClass(match)]]"></div> directive: myApp.directive('ngTippResult', function() { return { restrict: 'A', link: function(scope, elem, attrs) { var content = "s"; scope.$watch(attrs.ngTippResult,

Use same directive in same view and bind different data

谁说胖子不能爱 提交于 2019-12-24 08:24:14
问题 I have created a custom directive for displaying a charts made with the Highcharts library. Now I want to build upon this directive and create multiple charts in the same view. This is not possible with the current code I have, as you can see below. How can I organize my code so that it's possible to bind different data to it in the same view? Below is some example code to illustrate the problem. Directive function dateChart() { return { restrict: 'AE', scope: { title: '@' }, template: '<div

Angular Digest Loop on ng-style / Dynamic Photo Grid

徘徊边缘 提交于 2019-12-24 08:02:17
问题 I have a filter that changes filtered object. But when I'm using ng-style="item.gridSize" My Filter: (The Algorithm for size Grid was taken (changed for my needs) from Here angular.module("custom.modules.photoGrid", []).filter('photoSearch', [function () { function getGrid(photos){ var output = []; var HEIGHTS = []; var COLUMN_WIDTH = 227; var MARGIN = 6; var DELTA = 20; var size = window.innerWidth - 50; var n_columns = Math.floor(size / (2 * (COLUMN_WIDTH + MARGIN))); create_columns(n

In my service-factory I lookup up a large dataset - I want to persist it and check for its existence to avoid calling it again

本秂侑毒 提交于 2019-12-24 06:38:15
问题 My service (factory) makes an API call and assigns response data to a variable: .factory('MedicationMatchingNamesFactory', ['$http', '$q', 'MedicationDisplayNamesFactory', function MedicationMatchingNamesFactory($http, $q, MedicationDisplayNamesFactory){ return { getMatchingNames: function(inputValue){ var matches = []; // I thought this may be set as null so I'm able to // differentiate it from the below array form (when exists) var allNames = null; MedicationDisplayNamesFactory