angularjs-directive

Directive's isolated scope object is undefined

余生颓废 提交于 2020-01-05 16:47:25
问题 I'm new to AngularJS and trying to understand how to bind a directive's isolated scope with view's ng-model. The form should be valid when either inputs are empty or both filled with some values. Help me to find out why do I get "undefined" in a console log: .html: <form name="recipientsForm" novalidate> <md-input-container> <label>Name</label> <input name="name" type="text" ng-model="relationship.name" value="" empty-or-both-filled="relationship.relationshipType"> <div ng-messages=

how to defer a method execution in a directive in angularjs

若如初见. 提交于 2020-01-05 15:07:10
问题 I'm writing a directive which recives a function as a parameter, the directive executes and run whatever is contained into the function. the use case is: the directive contains a link when the user click the link the method passed as a parameter (from the controller) is executed when the user hit the click button a spinner will show the spinner will hide when the execution of the method is finished my question is how can I defer the execution and bind it to a promise, to hide the spinner

Call function from AngularJs Directive for Dropzone.js

青春壹個敷衍的年華 提交于 2020-01-05 12:32:30
问题 I've this directive for the dropzone.js script: GitHub This works fine but I want call the function processQueue() with a button. But I can't find how I can call this function! 回答1: I found the answer by myself, juste add this line in the end of the directive : scope.dropzone = dropzone; And next you can call the function like that : $scope.dropzone.processQueue(); 来源: https://stackoverflow.com/questions/28614980/call-function-from-angularjs-directive-for-dropzone-js

How do I properly build an AngularJS labeled radio input directive?

南笙酒味 提交于 2020-01-05 10:26:13
问题 I realize that AngularJS already has an input[radio] directive and I want to leverage that as much as possible. I created a JSFiddle here, but I can't figure out how to get the ng-model property to work properly. I'm selecting each radio, but the selectedValue doesn't change. Also, please tell me anything that I'm doing wrong here. I'm sure I could make some other improvements. The HTML: <div data-ng-controller="controller"> <div data-ng-repeat="radio in radios" data-ng-model="selectedValue"

Why isn't list of elements showing up?

狂风中的少年 提交于 2020-01-05 09:13:09
问题 I am working on an AngularJS tutorial This tutorial covers the ng-repeat directive, an AngularJS directive used repeating data. To show an example of ng-repeat, The author enters periodic table elements in a JSON format, covering element's name, element #, etc into controller logic($scope) To display the elements(code below), the author simply used the directive with a html un-ordered list <ul> <li data-ng-repeat="element in periodic.elements">{{element.name}} </li> </ul> I tried doing the

Replacement of $parent in AngularJS

牧云@^-^@ 提交于 2020-01-05 08:33:37
问题 Referencing my earlier post, why is the code using $parent here <fm-rating ng-model="$parent.restaurant.rating" readonly="true"></fm-rating> . The full code is here. I have been reading blogs which mention to avoid using $parent, hence my question. Is there a better way to write that code? Or is there no way, since the filters on the home page need to affect the results as seen in this screenshot of the app 回答1: fm-rating declares an isolated scope, as seen here, which means it does not use

Replacement of $parent in AngularJS

爷,独闯天下 提交于 2020-01-05 08:32:22
问题 Referencing my earlier post, why is the code using $parent here <fm-rating ng-model="$parent.restaurant.rating" readonly="true"></fm-rating> . The full code is here. I have been reading blogs which mention to avoid using $parent, hence my question. Is there a better way to write that code? Or is there no way, since the filters on the home page need to affect the results as seen in this screenshot of the app 回答1: fm-rating declares an isolated scope, as seen here, which means it does not use

Dynamically creating nested navigation menu item using Bootstrap and Angularjs

冷暖自知 提交于 2020-01-05 08:32:13
问题 What I want to achieve is dynamically creating a menu in bootstrap based on a json using angularjs. The json looks like this: { "Page A":"page_A.html", "Page B":{ "Page B1":"page_B/page_B1.html", "Page B2":"page_B/page_B2.html", "Page B3":{ "Page B3-a":"page_B/page_B3/page_a.html", "Page B3-b":"page_B/page_B3/page_b.html" } }, "Page C":"page_C.html" } where The object key is the name of the page and object value is the physical file location. The angular app.js look like this app.controller(

Dynamically creating nested navigation menu item using Bootstrap and Angularjs

☆樱花仙子☆ 提交于 2020-01-05 08:32:11
问题 What I want to achieve is dynamically creating a menu in bootstrap based on a json using angularjs. The json looks like this: { "Page A":"page_A.html", "Page B":{ "Page B1":"page_B/page_B1.html", "Page B2":"page_B/page_B2.html", "Page B3":{ "Page B3-a":"page_B/page_B3/page_a.html", "Page B3-b":"page_B/page_B3/page_b.html" } }, "Page C":"page_C.html" } where The object key is the name of the page and object value is the physical file location. The angular app.js look like this app.controller(

ReflectiveInjector is not instantiating component correctly with ngComponentOutlet Directive

浪子不回头ぞ 提交于 2020-01-05 08:17:23
问题 Here is an example Plunker. Any help is appreciated! @Component({ selector: 'component1', template : ` <h3>{{title}}</h3> <button (click)='dismiss()'>dismiss</button> <ng-container *ngComponentOutlet="Component2; injector: myInjector; content: myContent"> </ng-container> ` }) export class Component1 implements OnInit{ title : string = "hello!"; myInjector: Injector; myContent: any; constructor(private injector : Injector){ this.myInjector = ReflectiveInjector.resolveAndCreate([ { provide :