angular-template

What is a better way and how to achieve sending object from one nested component to another

送分小仙女□ 提交于 2019-12-11 05:59:57
问题 I'm working on simple application about products, basically when user choose a product it should be sent to another component which would hold product. Product is allways choosen one by one, I am NEVER sending a LIST ! Only item by item ! So basically when I click on any of products in the middle of screen ( Product food 1, Product food 2, Product food 3 ) it should be sent to the right part of the screen which is also separated component. So my middle component looks like this: <div *ngFor=

AngularJS templateUrl vs template - isolate scope

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-11 01:28:52
问题 I have the following directive: offerListSorters.directive('offersSorter', ['myState', '$templateCache', function (myState, $templateCache){ return { scope: {}, controller: function($scope, $element, $attrs, $transclude) { [...] }, restrict: 'E', //templateUrl: 'partials/offersSorterDirective.html', template: $templateCache.get('partials/offersSorterDirective.html'), replace: true, transclude: true }; }]); And I use Karma + Jasmine to test this code and it works. But now if I switch to the

Angular html file not found in component library

允我心安 提交于 2019-12-10 16:59:31
问题 I'm building a component library for angular which we will share across projects. But when i build the package the html files don't get copied to the dist folder. I get the error angular Failed to load text-input.component.html . This is my tsconfig.json: { "compileOnSave": false, "compilerOptions": { "outDir": "./dist", "baseUrl": "src", "sourceMap": true, "declaration": false, "moduleResolution": "node", "emitDecoratorMetadata": true, "experimentalDecorators": true, "target": "es5",

Loop through array of strings - angular2

心已入冬 提交于 2019-12-10 14:11:40
问题 Yet very basic thing, but I am unable to figure out how to display array of strings in html template in angular2. .html <ul> <li *ngFor="#number of numberOptions"> {{number}} </li> </ul> .ts this.numberOptions= ["I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X"]; The above trick is not working for me, text editor shows error for #number in ngFor . Is this deprecated in new versions? or am I doing anything wrong here? 回答1: You have to declare the variable number with let . <li *ngFor

Javascript ads in Angular templates

笑着哭i 提交于 2019-12-10 03:59:35
问题 I'm trying to render a Javascript ad in my Angular template but it will not show up. I've found some solutions when they append the Javascript to the head tag but I want the ad to be placed in my Html (inside body). Here is a Plunker: https://plnkr.co/edit/WHhQ95gS5HKSphmmirio Here is a simple plain Html example that works. <html> <head> </head> <body> <div class="ad"> <script src="http://media.affiliatelounge.com/data/nordicbet/ad_js/display_88.js?ad=ad_793270_88.html&size=300x250&clicktag

Angular5 template binding, callback function called more than once

懵懂的女人 提交于 2019-12-09 13:37:06
问题 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

Angular2 + ng2-material import

╄→гoц情女王★ 提交于 2019-12-08 19:06:26
I'm using angular 2 with ng2-material to display radio and checkbox components, in each component I see that I have to import all the ng2-material contents and finally using only one component => the result, it charges my app and makes it slower. I want to know if I may import only the component that I need, despite that in the ng2-material documentation they are importing all of them ??? import {Component} from 'angular2/core'; import {bootstrap} from 'angular2/platform/browser'; import {MATERIAL_DIRECTIVES, MATERIAL_PROVIDERS} from "ng2-material/all"; <<<<< import {ROUTER_DIRECTIVES} from

Angular2 + ng2-material import

☆樱花仙子☆ 提交于 2019-12-08 07:54:53
问题 I'm using angular 2 with ng2-material to display radio and checkbox components, in each component I see that I have to import all the ng2-material contents and finally using only one component => the result, it charges my app and makes it slower. I want to know if I may import only the component that I need, despite that in the ng2-material documentation they are importing all of them ??? import {Component} from 'angular2/core'; import {bootstrap} from 'angular2/platform/browser'; import

How to filter second dropdown based on selection of first dropdown? - Angular

 ̄綄美尐妖づ 提交于 2019-12-08 05:24:54
问题 I have a two dropdowns that looks like this: so my plan is to load all subcategories, but I would like to display in dropdown only these which are related to selected Category ( that one which contain ParentId as Id of selected Category). And here is my code: <!--Category--> <div class="form-group"> <label class="control-label dash-control-label col-xs-3">Category:</label> <div class="col-xs-9"> <select class="form-control select2" style="width: 100%;" data-minimum-results-for-search=

What is ng-template and why do I bind *ngIf then else to it?

◇◆丶佛笑我妖孽 提交于 2019-12-06 11:33:59
When I use *ngIf with a then and/or else statement, why do I have to bind to a template variable that is attached to a ng-template element? For example: This works: <div *ngIf="show; else elseBlock">Text to show</div> <ng-template #elseBlock>Alternate text while primary text is hidden</ng-template> But this does not work: <div *ngIf="show; else elseBlock">Text to show</div> <div #elseBlock>Alternate text while primary text is hidden</div> I also noticed adding a class does not work either: <ng-template #elseBlock class="my-class"> Alternate text while primary text is hidden </ng-template> What