angular-template

Angular2 form ControlGroup who hold an undefined number of Control

北战南征 提交于 2019-12-03 18:06:00
问题 How to manage with Angular2 a form who hold an undefined number of field ? In my case, I need to create a from where user can add and delete some block of fileds. It's like an address book where user can add one or ten address. And each address had a some fields like street, street number and so on. My look like this : let address = fb.group({ street: fb.control(null, Validators.required), streetNumber fb.control(null, Validators.required) }); this.userForm = fb.group({ name: fb.control(null,

Angular5 template binding, callback function called more than once

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-03 16:29:54
I tried to implement a grid component with a structured data containing columns definition and its data array . There is a callback function in the definition of each column, to customize displaying the value of that column. Inside of each callback , it called a console.log() to show me how many times the callback function will be called. I don't know why callback function called four times in the beginning, and two times after changeSort() event fired !! Please let me know. I wrote the following table component: import { Component, OnInit, Input } from '@angular/core'; @Component({ selector:

Angular JS ng-include binding issues

一笑奈何 提交于 2019-12-03 15:40:25
I have created a pager widget using template file which I am using twice in my HTML page. I have a select for go to page option and also links for previous and next page. Problem is that when I use select box for updating current page its updated and then I use previous and next page links, the current page gets updated but select box doesn't get updated. Please tell me what I am doing wrong. Is there any logical mistake in my approach to building a pager widget like this? Controller Code: var gallery = angular.module('gallery', []); gallery.controller('ItemListCtrl', ['$scope', function(

How to handle template errors (and other errors) in angular 2?

空扰寡人 提交于 2019-12-03 14:19:55
When ever there is a template error in angular 2, the entire application fails to work. Shouldn't only the component that had the template that caused the error, fail to work and the rest of the application be working fine? How to handle errors so that the application won't stop being responsive when an error occurs? You can use custom ErrorHandler : class MyErrorHandler implements ErrorHandler { handleError(error) { // do something with the exception } } @NgModule({ providers: [{provide: ErrorHandler, useClass: MyErrorHandler}] }) class MyModule {} Using ? mark is a solution around this while

Angular - ng-template with parameter inside ngIf inside ngFor [duplicate]

℡╲_俬逩灬. 提交于 2019-12-03 08:14:40
问题 This question already has answers here : Passing ngFor variable to an ngIf template (3 answers) Closed last year . I am trying to build this template: <ul> <li *ngFor='let link of links'> <ng-container *ngIf="link.type == 'complex'; then complexLink else simpleLink"></ng-container> </li> </ul> <ng-template #simpleLink> ... {{ link.some_property }} </ng-template> <ng-template #complexLink> ... {{ link.some_property }} </ng-template> The problem is that the link variable is undefined inside the

Angular - ng-template with parameter inside ngIf inside ngFor [duplicate]

帅比萌擦擦* 提交于 2019-12-03 01:09:45
This question already has an answer here: Passing ngFor variable to an ngIf template 3 answers I am trying to build this template: <ul> <li *ngFor='let link of links'> <ng-container *ngIf="link.type == 'complex'; then complexLink else simpleLink"></ng-container> </li> </ul> <ng-template #simpleLink> ... {{ link.some_property }} </ng-template> <ng-template #complexLink> ... {{ link.some_property }} </ng-template> The problem is that the link variable is undefined inside the ng-template so I get an error of accessing 'some_property' of undefined. I am struggeling to understand how I pass the

How to hide unused items with ngFor ionic?

梦想与她 提交于 2019-12-02 06:12:48
问题 im trying to hide unused items from ngFor, the problem is, i did hide it successfully but its place still exists and empty like the image below: My ts file: coupon: any; couponz() { var data=[]; for (let co of this.shared.couponz){ data.push({ code: co.code, coEmail: co.email_restrictions[0], expiry: co.date_expires }); this.coupon = data; console.log(this.coupon) }return data } my data provider: @Injectable() export class SharedDataProvider { public couponz; this.config.Woocommerce.getAsync(

Angular Directive with dynamically generated input fields not able to display validation

[亡魂溺海] 提交于 2019-12-02 04:41:14
问题 After 3 days of scouring stackoverflow and other sites, I have found myself back at square one. My task: I need to validate dynamically generated form fields. The HTML: <form name="myForm"> <form-field content="field" model="output[field.uniqueId]" ng-repeat="field in formFields"></form-field> </form> The controller: var myApp = angular.module('myApp',[]); function MyCtrl($scope) { $scope.formFields = [ { "fieldName": "Your Name", "uniqueId": "your_name_0", "fieldType": "text", "isMandatory":

How to hide unused items with ngFor ionic?

房东的猫 提交于 2019-12-02 02:12:08
im trying to hide unused items from ngFor, the problem is, i did hide it successfully but its place still exists and empty like the image below: My ts file: coupon: any; couponz() { var data=[]; for (let co of this.shared.couponz){ data.push({ code: co.code, coEmail: co.email_restrictions[0], expiry: co.date_expires }); this.coupon = data; console.log(this.coupon) }return data } my data provider: @Injectable() export class SharedDataProvider { public couponz; this.config.Woocommerce.getAsync("coupons/").then((data) => { this.couponz = JSON.parse(data.body); }); my html: <ion-list padding> <ion

Angular Directive with dynamically generated input fields not able to display validation

风格不统一 提交于 2019-12-02 01:44:44
After 3 days of scouring stackoverflow and other sites, I have found myself back at square one. My task: I need to validate dynamically generated form fields. The HTML: <form name="myForm"> <form-field content="field" model="output[field.uniqueId]" ng-repeat="field in formFields"></form-field> </form> The controller: var myApp = angular.module('myApp',[]); function MyCtrl($scope) { $scope.formFields = [ { "fieldName": "Your Name", "uniqueId": "your_name_0", "fieldType": "text", "isMandatory": true }, { "fieldName": "Description", "uniqueId": "description_1", "fieldType": "textarea",