angularjs-components

Pass object to component

删除回忆录丶 提交于 2021-01-26 19:49:48
问题 I have created a component that needs to have a reference to the object for which the component was created. I didn't make to work and all my trials have failed. Below, I try to describe the intention. The component definition would maybe look like this: angular .module('myModule') .component('myComponent', { templateUrl: "template.html", controller: [ MyController ], bindings: { myObject: '=' } }); function MyController(myObject) { var vm = this; vm.myObject = myObject; } In a service I

Pass object to component

强颜欢笑 提交于 2021-01-26 19:49:11
问题 I have created a component that needs to have a reference to the object for which the component was created. I didn't make to work and all my trials have failed. Below, I try to describe the intention. The component definition would maybe look like this: angular .module('myModule') .component('myComponent', { templateUrl: "template.html", controller: [ MyController ], bindings: { myObject: '=' } }); function MyController(myObject) { var vm = this; vm.myObject = myObject; } In a service I

Pass object to component

两盒软妹~` 提交于 2021-01-26 19:48:35
问题 I have created a component that needs to have a reference to the object for which the component was created. I didn't make to work and all my trials have failed. Below, I try to describe the intention. The component definition would maybe look like this: angular .module('myModule') .component('myComponent', { templateUrl: "template.html", controller: [ MyController ], bindings: { myObject: '=' } }); function MyController(myObject) { var vm = this; vm.myObject = myObject; } In a service I

How to validate form in AngularJS 1.x component

删除回忆录丶 提交于 2020-02-04 11:43:46
问题 I have a form that its fields are inside the component. Now I want to validate the fields. The problem is, my messages don't show up. also the pattern doesn't have any effects. I tried to fix it with help of this post, but no success. Does someone have any idea how can I show my messages? index.html <form name="dataForm"> <md-tabs> <valid-data form-reference="dataForm"></valid-data> </md-tabs> <div> <md-button type="submit" ng-click="vm.save()"> Save </md-button> </div> </form> component.html

Pass bindings to TemplateUrl in Angular's component

白昼怎懂夜的黑 提交于 2020-01-03 16:01:04
问题 My component object looks like this: var options = { bindings: { title: '<', rows: '<' }, controller: registers, templateUrl: function ($element, $attrs) { return '/app/dashboard/registers/register.html'; } }; I need access to the bindings title and rows in my register.html markup. I understand $element and $attrs but I'm not quite sure how to inject that into a templateUrl which is a string reference to an HTML file. I would like to be able to use those values in the template as such: <p

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: [

Pitfalls of the New AngularJS ng-ref Directive

99封情书 提交于 2019-12-23 07:47:14
问题 The release of AngularJS V1.7.1 * introduces the new ng-ref directive. While this new directive enables users to easily do certain things, I see great potential for abuse and problems. The ng-ref attribute tells AngularJS to publish the controller of a component on the current scope. This is useful for having a component such as an audio player expose its API to sibling components. Its play and stop controls can be easily accessed. The first problem is the player controls are undefined inside

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

How to test Angularjs route's resolve value on component?

China☆狼群 提交于 2019-12-23 05:10:40
问题 I'm using angular@1.5.8 and resolve some resource at the route level for one of my component. The component works as expected but my test fails now. Error PhantomJS 2.1.1 (Linux 0.0.0) module ag.expense-claim ExpenseClaimController: should load data FAILED TypeError: undefined is not an object (evaluating 'vm.attachedReceipts.results') (line 16) ExpenseClaimViewController@app/expenses/expense_claim.js:16:50 ExpenseClaimViewController@[native code] instantiate@node_modules/angular/angular.js

How to pass ngModel to AngularJS component without 2-way binding?

穿精又带淫゛_ 提交于 2019-12-23 03:58:07
问题 I have custom input as AngularJS 1.5 component with one-way data bindings and ngModel as two-way data binding: return { bindings: { form: "<", fieldName: "@", minLength: "@", maxLength: "@", isRequired: "@", errors: "<", value: "=ngModel" }, templateUrl: "actTextField.html", controller: ActTextFieldController, } in file actTextField.js in provided Plunk. I want to follow A new Angular 1.x ES2015 styleguide, the path to Angular 2 where Todd wrote: We no longer should utilise two-way data