angular-dart

What is the annotation equivalent of map: const {'foo':'&foo'} in AngularDart?

梦想与她 提交于 2019-12-20 02:14:07
问题 I see that this StackOverflow question shows how to bind to a field that contains a function: @NgComponent( selector: 'mycomp', publishAs: 'ctrl', map: const { 'myfunc' :'&myfunc' } ) class MyComponent { Function myfunc; However, it is recommended to use annotations to declare what fields are bound, and how. I see @NgOneWay ( => ) and others, but I don't see an annotation for &myfunc . What annotation should I use? 回答1: Ok, just saw you created a new question for this one: For callbacks & use

How to access angular.dart component´s attribute or method

帅比萌擦擦* 提交于 2019-12-19 19:56:38
问题 I defined an angular.dart component like this: @NgComponent( selector: 'dartcomp', templateUrl: 'dartComp.html', publishAs: 'ctrl', map: const { 'val' : '@val' } ) class DartComp { String val; calc(a,b) =>a+b; } the usage in the HTML is: <dartcomp id="dc"></dartcomp> How to access angular.dart component´s attribute val or method calc() from the main dart a call to the component like querySelector("#dc").val = "Frank"; throw: Class 'UnknownElement' has no instance setter 'val='.

How can I Dependency Inject based on type and name, with AngularDart?

≡放荡痞女 提交于 2019-12-19 04:09:21
问题 I have two services, each of which takes a different WebSocket as a constructor parameter. I'd like to use AngularDart's dependency injection to pass in the WebSocket connection, but I can't rely on types alone (as I have two WebSockets). How can I annotate or specify which specific WebSocket connection should to each service? Let's pretend I have: class ServiceOne { WebSocket socketOne; ServiceOne(this.socketOne); } and class ServiceTwo { WebSocket socketTwo; // different connection

Angular2 Dart - Get Text inside Angular2 Component

痴心易碎 提交于 2019-12-19 04:06:05
问题 I've got an item component which I use inside other components, the item component typically looks like this: <item type="the-type" text="the-text"></item> and is defined like this: @Component( selector: 'item', template: '...') class Item { @Input() String text = "text-goes-here"; @Input() String type = "type-goes-here"; } Now I want to change the item so that it has a more natural feel to it: <item type="the-type">the-text</item> Now I want to get the text the-text from this component. I

Why does Angular not need a dash in component name

落花浮王杯 提交于 2019-12-18 14:17:46
问题 I wondered why Polymer elements need a dash in custom elements name like <my-component> while this is not necessary for Angular components especially as Angular components also use ShadowDOM. ** Edit** It doesn't even seem to be suggested good practice in Angular. 回答1: The HTML spec allows you to use unknown tags ( <tab> , <panel> ) without the HTML parser throwing a fit. To their benefit, Angular uses this behavior for their directives to make the components like native. Tags that don't have

Get ng-model validation status in Dart code

早过忘川 提交于 2019-12-18 09:26:03
问题 When I use <input type='text' maxlength='25' required ng-model='ctrl.inputValue'> Angular adds several classes like ng-valid , ng-invalid , ng-dirty , ng-pristine to the element that allow showing visual indicators about the validation result. Is there a way to these status in Dart code? 回答1: Okay so I have just looked in to this: Take the following code (Form and names are important!): <div test> <form name="myForm"> <input type='text' name="myInput" maxlength='25' required ng-model='ctrl

Can I put ng-if directive on an element which also binds to a controller

隐身守侯 提交于 2019-12-18 08:27:30
问题 I was wondering in case I have a controller and ng-if directive on the same element as in <div foo ng-if=“ctrl.visible”>You can see me</div> and a controller, something like NgController(selector: ‘[foo]’,….) class FooController { var visible = true; } Should I see the text “You can see me" or not? 回答1: Here's the answer. I would not see the text. Basically, ng-if is a transcluding directive which means that the entire element is ripped out of the DOM and no other directives are instantiated

Can I put ng-if directive on an element which also binds to a controller

落花浮王杯 提交于 2019-12-18 08:27:14
问题 I was wondering in case I have a controller and ng-if directive on the same element as in <div foo ng-if=“ctrl.visible”>You can see me</div> and a controller, something like NgController(selector: ‘[foo]’,….) class FooController { var visible = true; } Should I see the text “You can see me" or not? 回答1: Here's the answer. I would not see the text. Basically, ng-if is a transcluding directive which means that the entire element is ripped out of the DOM and no other directives are instantiated

What is the equivalent annotation for the old map/@attr in AngularDart?

懵懂的女人 提交于 2019-12-18 04:26:05
问题 The AngularDart tutorial (at of the time of this writing), recommends binding component fields to attributes like this: map: const { 'max-rating' : '@maxRating', 'rating' : '<=>rating' } However, I see also that Angular has @NgOneWay , @NgTwoWay , and others. I can't find the annotation for @ . Which annotation do I want if I want the same semantics as @maxRating ? Apparently: @NgOneWay == => @NgTwoWay == <=> @NgOneWayOneTime == =>! ??? == @ 回答1: I think @NgAttr is what you are looking for.

Angular2 dynamic change CSS property

一个人想着一个人 提交于 2019-12-17 08:35:42
问题 We are making an Angular2 application and we want to be able to somehow create a global CSS variable (and update the properties' values whenever changed when the variable is assigned). We had used Polymer for a while (now we are switching to Angular2 components) and we had used CSS properties (Polymer has some polyfill) and we had just update styles using Polymer.updateStyles() . Is there any way how we can achieve a similar function? EDIT: We want something similar to Sass color: $g-main