That site has a very spammy appearance. I also like that the video downloader you ~~are paid for to link to~~ recommend has a fake download counter on their website. The elements id is "myTargetElement" as if it was copied from some JS introduction course. They even left the comment with the playground URL in there: https://stackblitz.com/edit/countup-typescript
This is a cool idea I came up with that involves multiple nested divs, but I'm not really sure what can be made with it.
I'm offering it as an idea for building some kind of bad UI, feel free to use this idea however you want!
Source: https://stackblitz.com/edit/web-platform-em2rqe?file=index.html
In "the Angular world" this is called and "overlay", not a "dropdown". There are several ways to do this. I can show you three examples:
I forked + fixed your example
​
You had a syntax error in the template - missing `;` in the *ngIf
I also implemented the remove method. All it does is call 'next' on the text Subject with the modified value.
​
You are welcome :D
I forked your blitz and updated the code. https://stackblitz.com/edit/gitclone-vod9r4
what I did was:
const [list, setList] = useState(0);
const [listData, setListData] = useState([]);
then passed the listData to your Card component.The whole point of Redux isn't simplicity, it's about replayability. If you can go back/forward on each state change step, then it adds an element of resilience/debuggability to your app.
To do this you gotta drink all of the Redux cool-aide, exactly as it's spelled out or it's not worth it at all.
If time travel is not valuable to you, then it's not worth using Redux - writing reducers, selectors and all that is a lot of work for proportionately small functionality.
Just use vanilla js, streams and some factory functions to make stores pertaining to domains of your front end.
Here's an example:
https://stackblitz.com/edit/react-mbqymp
Ya'll overcomplicate front end
You need to import SettingsModule into the AppModule - since it's a feature module of your application and it is not lazy-loaded.
​
I added it to your stackblitz:
This side-by-side Redux vs Mobx comparison also might be interesting for you:
https://stackblitz.com/edit/reacto-s2ed7g
At a recent meetup Ben Shell presented an overview of the new context API. He had an example about Redux and I added an example doing the same thing in MobX.
Look in these files for the comparison:
Slide 8: an app that manages some state in Redux. backed by code in \examples\ReduxApp2.js
Slide 9: the same app backed by MobX backed with a side-by-side comparison of the MobX code vs the Redux code in \examples\MobXApp.js
To see the MobX without all of the commented Redux you can look at \examples\MobXAppOnly.js
async pipe doesn't need to be unsubscribed. You can also avoid dependent observable subscriptions by pooling all observable in a global async pipe - https://stackblitz.com/edit/subscribing-to-multiple-observables?file=app%2Fasync-pipe-object%2Fasync-pipe-object.component.html
Eu acho q o vekstir matou a charada do pq o código n está compilando.
Uma dica q eu daria é para vc n se acostumar a usar var. Use const ou let ao invés disso.
Além disso, javascript tem métodos de loops e manipulação de arrays como o forEach() e o .map(). Que podem dar uma simplificada nesse teu código ai. Só que vc vai ter q trabalhar com callbacks, oq pode ser meio confuso para um iniciante.
Vai ser muito raro você escrever um for trabalhando com javascript por exemplo. Eu pessoalmente nem lembro qnd foi a última vez q eu escrevi um for husahusua.
N sei como vc está escrevendo código, mas usar até msm um https://stackblitz.com/ da vida para codar vanilla js vc poderia ter pegado esse errinho pq o stackblitz qnd eu salvei o teu código mudou na hora ali o ==! e vc teria visto que estaria errado.
don't create new mapped observables in getters, each time the change detector runs, it will create a new subscription because each time it runs, a new observable is created by the getter... instead, assign mapped observables to instance variables/properties...
Just tried it out on https://stackblitz.com/, and it's actually really impressive. It's just plain fun to be able to type 'mobx' and 'mobx-react' into the dependencies and have both installed and ready to rip in a couple seconds.
The editor itself actually pulls up (much) faster than VC Code does in my own computer.
Great job!
This is very common, and 100% doable.
Check out this stackblitz: https://stackblitz.com/edit/routing-layouts?file=src%2Fapp%2Fapp.module.ts - Essentially what it is is for every Module / component you give it a layout to load when initializing it via the data property. This makes apps extremely flexible. With this approach any part of the app can have a different layout if needed. This is the approach that I am using.
Depending on the sizes of your app, I would also recommend separating your apps apart. You could do an app, and an admin app. Angular CLI now lets you create multiple apps in the same project. You can also have a shared project for stuff that needs to be shared.
If you watch to be able to stretch the image horizontally, you'll need to set the SVG's "preserveAspectRatio" attribute to "none". (By default, SVGs "fit" the viewbox into the render region, but this change will make an SVG behave more like a traditional image tag.)
After that you can set the SVG width to 100% in CSS.
Example: https://stackblitz.com/edit/angular-a8sle3
Note that this will literally stretch the image, warping line thicknesses and corner radii. If you want the boxes to stretch like a responsive website, you'll probably want to use HTML+CSS instead of SVG to solve this problem.
Controls can be dirty. I made a little stackblitz example: https://stackblitz.com/edit/angular-diffed-form-example-for-reddit
I used a filter over a FormArray
to only return the controls that are marked dirty. This logic is very crude but it gets the point across.
I have a couple of thoughts. First, make your mouse events into an event stream in rxjs (use fromEvent()
). Next, don't use document.getElementById()
. Finally, investigate using event coallescing.
I was able to get your StackBlitz working. Your resize logic doesn't work correctly, but it is pretty smooth now. You can uncomment the throttleTime()
if you don't want to introduce event coalescing to your actual application.
https://stackblitz.com/edit/angular-ivy-aljbur?devtoolsheight=33&file=src/main.ts
I added a bunch of logging to your original code to give you an idea of where the events are handled. This was a fun challenge to figure out how to get all the events to work together.
Definitely possible. Here's a quick and ugly example of one way to do it:
https://stackblitz.com/edit/angular-ivy-tj9ubc?file=src/app/app.component.html
This is a shitty example and definitely not ideal and like other users have pointed out it's probably best to go the directive or component factory route.
Dumb but simple solution:
Here is a working stackblitz. I just hacked something together you can do better for sure.
​
Just use an EventEmitter in your child component and emit showValue after validation. Then you can do whatever in your parent component with it.
Here's a very simple demo of what you need: https://stackblitz.com/edit/angular-date-timer?file=src/app/app.component.ts. The timer updates every second with the number of milliseconds from now to that day. I hope it's clear enough! Reach out to me if you need anything else.
Do you know that Angular encapsulates styles by default?
Styles in child component won't be applied to parent component.
Can you provide a stackblitz example, so we can debug it?
Yes, you should put the todos in a service. As u/vicmarcal said, using a Subject will simplify the code. Basically you do all the data fetching and manipulation in the service, and then you "emit" the data. The components listen to those emissions. It's a bit like an event emitter, you had the right idea.
Here is a small example.
You can run GitHub repositories created with Angular CLI in StackBlitz.
stackblitz.com/github/{GH_USERNAME}/{REPO_NAME}
https://stackblitz.com/github/cu0ngpitt/weather-app
Some bug with newer CLI projects though but adding this to polyfills.ts should fix it:
import 'core-js/es7/reflect'
I've forked that StackBlitz and made some changes on it. It doesn't use the share() operator, but it will call the service only once. Also uses the async pipe and filters the response by the query string.
.idea
directory, that contains your entire dev setup. File watchers, open files, cursor position, all that jazz. Simply commit it to Git alongside project files or any other source control system, and you'll have access to it anywhereStraight way without infinity scroll looks like this
https://stackblitz.com/edit/angular-more-data-from-list?file=src%2Fapp%2Fapp.component.ts
you can trigger nextPage() on scroll instead of button click
I wish I had this when I was studying. Angular Material Table with Search, Checkboxes, etc I'm slowly adding features to it to help others and I refer noobs to it almost every day. You can fork it and add more of what you want to teach and go from there. Connect to Firebase, set up on AWS, add Nestjs / TypeORM on say Postgres, that sort of thing besides features.
I would avoid the books. They are often obsolete and go too detailed into each topic. Learners need the big picture and they need relevancy. Learning CRUD and setting up a DB / server will get them excited. They can dig deeper later. Don't take shortcuts like Mongo without next setting up a server even if they have to copy all the code. Get them to CRUD ASAP. Fill in the gaps later.
You are trying to access this.updateFavorites()
but it seems like you are not placing on "this".
If you are using a class you just need to write:
updateFavorites = () => {...}
Or, if you want to create updateFavorites as part of the render function, there is no need for "this."
You don't need to write onClick={() => this.updateFavorites()}
you can just write onClick={this.updateFavorites}
In the first version you are passing a callback that calls your function but in the second version you are passing updateFavorites as a callback.
Your console.log will not display the correct data. setState is not synchronous and the data displayed will not be updated, instead try doing something like this:
this.setState({
favorites: [...this.state.favorites, this.state.movies.imdbID]
}, () => {console.log(this.state.favorites)})
I created a small example of the two ways to use updateFavorites here.
I hope I could help
Aight I'm going to do a top level comment with a full explanation. When I tested the example again, when one select value changed, it was changing other selects too even though the array was functioning properly. This lead me to beilieve that angular was having trouble tracking values in the array.
Therefore, I provided a track by function for angular. New ngFor, sorry i'm not used to templates, just used a div
<div *ngFor="let t of contactTypes; index as i; trackBy: trackByFn">
I made an update to the binding of the select box, although this might be unnecessary, it's good pattern to perform side effects on select box change.
<mat-select name="{{i}}" [ngModel]="contactTypes[i]" (ngModelChange)="contactTypes[i] = $event" placeholder="Contact type">
Full code including track by function is here. https://stackblitz.com/edit/angular-material-bcgfnf?file=app%2Fapp.component.html
Saying that primitive types are not change detectable is a pretty big statement, and brings into question the usefulness of the framework. I don't believe it to be true in any way. After all, objects are just wrappers around primitives.
Also, according to u/talleane, angular runs change detection on the entire DOM on each triggered event, therefore this is not a good pattern in terms of performance. Instead use OnPush change detection.
I took the chance to provide an example of ReactiveForms that solves your problem since it is the preferred way to do forms in Angular6 at this point.
Forked stackblitz: https://stackblitz.com/edit/reddit-generated-form-controls
I tried to comment things to clarify what I was doing if you haven't used ReactiveForms before. If you have any questions feel free to ask.
Might be a better way to do this, but I'm too tired to bother any further.
I worked with Angular a while back, and they use something called Dependency Injection System to solve this same exact problem, but the DI system seems to be so much more elegant, you create an injectable service (which is just an ES6 class with @Injectable decorator) and provide it at module level which groups a bunch of components.
The @Injectable class will act as a singleton across all the components in the module, and any component (ES6 classes) can inject the service though its constructor (by using service's class type as injection token), then components interact with it and share state through it.
Would something like this be possible in React? I would much rather prefer a DI system than context API (because it seems a little bit convoluted), especially if it's as good as Angular's
Just to give you an example, here, both components with display Username: Alan
until ComponentB clicks on change username button
, then both components will show Username: John
(this is the simplest example, the Di can provide a service which itself can inject multiple other services, etc, etc)
This is great! I also came across StackBlitz which is awesome for larger projects and the ability to import modules, but I like yours a lot for quick code snippets. Much better than the TS Playground. I'm also not sure that StackBlitz gives you all the compiler flags.
One suggestion: might be nice to include the compiler settings in the URL?
https://stackblitz.com/edit/angular-mzhmhk?file=app%2Fapp.module.ts
Check out this snippet - of course you are able to do the exact same pattern. The problem with this approach is that in Angular it's more verbose. Also classes play better with types - with your approach you can either ignore them ("any" type, see source in stackblitz) or keep them in check with actual code manually.
*edit: Nevermind the types issue, turns out that factory functions can work just as well as classes, see stackblitz.
Aslong as all of your Components are defined inside the app then you can do something like this
https://stackblitz.com/edit/angular-dynamic-content-viewer?file=app%2Fapp.module.ts
If you need any more than that then I think you want to wait for Angular Elements
Use this online IDE for learning purposes, you don't need to install anything on your mac/pc: https://stackblitz.com/edit/angular-rocmr7
As for your difficulties learning Angular, you'll just have to power thought it man, like everyone else, Angular is not easy to learn, but the payoff is worth it, it's a very powerful framework, a lot of companies are also looking for a good Angular devs.
Personally I started learning Angular though Max's Udemy course (it's 15 bucks or something), a few courses every evening before going to bed, then started building things with it even if they sucked, but though iteration, failure and looking how other devs do, you learn, it's a normal learning process, don't worry you'll get there.
In the official Angular Material documentation they provide an example where they use function calls in the HTML to determine certain things about checkboxes. Would it somehow be possible to achieve the same without function calls?
https://stackblitz.com/run?file=src%2Fapp%2Fcheckbox-overview-example.html
It's only the PWA without a real backend, so there is no server that could run any processes or certain extensions. That's also the reason why you don't have a terminal there. Same for github.dev
So as already suggested, Codespaces (or maybe a self-hosted instance of the VS Code PWA) is the only option here.
You could also try stackblitz.com, they give you a console and have a live server built in, that probably fits your bill.
https://stackblitz.com/edit/angular-ivy-zfrkrb?file=src/app/app.component.ts
​
I hope this link works, I messed up when copying the other one
I created a StackBlitz trying to reproduce this issue, but I didn't get the same behavior.
https://stackblitz.com/edit/angular-ivy-9if8zd?devtoolsheight=33&file=src/app/app.module.ts
I did have to make sure to import the HttpClientModule
in the AppModule
. Can you modify this to reproduce your error? If I can see the error, I can better understand what is causing the issue.
Take a look at my library ez-state, it does exactly this but manages the behavior subjects for you giving you getters that create behavior subjects for loading, saving, errors states etc.
Ya, StackBlitz is just the site I used to host it real quick and record a gif.
You can visit the edit link to see the source (link is not mobile friendly): https://stackblitz.com/edit/js-emxzfx?file=index.html
Here is an example: https://stackblitz.com/edit/angular-ivy-shbldg
as you see I created two pipes and the second pipe is more generic so you can define also the length.
However I don't like this solution, I created also second solution. In the second solution I use css to show a part of the text.
CONS:
If your description is too long then you have a lot of text in your dom element but you (as user) don't see it. Solution: Use SliceStringPipe with length 100 of something like this.
PROS:
Cheaper processing, less codes ( no pipes ), and most important visually this looks beter. Because you see always two ( four whatever you want ) lines of the description.
I see, could you take a look at this? https://stackblitz.com/edit/ngx-editor-rtpcvr?file=src/app/app.component.ts
Seems to work as you want - the only thing is that parsing HTML gets very complex. So it works great for regular text, but introducing lists (which you allow in the toolbar) can get tricky. You'd have to update the regex to accommodate those.
you can use function overloads, but those always come with the caveat that it's up to your implementation to make sure the right types are returned from the right inputs: playground
Have you tried a conditional type based on the value of key
, something like this?
public getData$<Slice extends keyof TState, DataKey extends keyof TState[Slice]>( slice: Slice, key?: DataKey | undefined, defaultValue?: TState[Slice] | TState[Slice][DataKey] | null ): Observable<typeof key extends DataKey ? TState[Slice] : TState[Slice][DataKey]>
The key difference being: typeof key extends DataKey ? TState[Slice] : TState[Slice][DataKey]
.
I think it's working based on what I see from a forked instance of your example, although one of the return types from the wrapping function doesn't seem to match:
CP gives you more flexibility. You can build some sort of "wrapper" component and insert different content on different parts of your app.
A good example are the form-fields from Angular Material.
They have a component "mat-form-field" that applies some styles and common functionality but it is your choice what kind of <input>
, label and icon you put into it.
<mat-form-field appearance="standard"> <mat-label>Standard form field</mat-label> <input matInput type="email" placeholder="Placeholder"> <mat-icon matSuffix>mail</mat-icon> </mat-form-field>
<mat-form-field appearance="standard"> <mat-label>Standard form field</mat-label> <input matInput type="number" placeholder="Placeholder"> </mat-form-field>
While possible, this is just unnecessary. Detecting updates of property-bindings and updating the template accordingly is one of THE fundamental principles of Angular.
Take a look at this very simple example. The button in the app.component just appends a number to the name. The new name is automatically passed to the child component. I would consider using setter with Input() as a bad practice. If you want to do something on a property update, implement the OnChanges interface.
To understand how this all works i would highly suggest you to work through the official Angular tutorial and read up on the change detection.
What do you mean by used inside a loop? As in mapping over some items? If so you probably need to extract each child to its own component and contain it's own local state. something like this: https://stackblitz.com/edit/react-kv5r2d?file=src/App.js
First change: Moved form initialization to ngOnInit.
public parentForm: FormGroup; ngOnInit() { this.parentForm = new FormGroup({ ... }); }
Second change: Added a method to grab controls to the form array, typed as FormControl.
<app-child [formControl]="fetchStepControl(i)" [index]="i"></app-child>
public fetchStepControl(index: number): FormControl { return this.steps?.at(index) as FormControl; }
Third change: Since your subform has its own validators and validates as "invalid" by default, that seems to cause a problem that reactive forms doesn't cope with well. Immediately after initializing the form, you'll need to give the change detector a kick in the pants:
constructor( private changeDetectorRef: ChangeDetectorRef ) {}
ngOnInit() { this.parentForm = new FormGroup({ ... }); this.changeDetectorRef.detectChanges(); }
The above is the official way to properly detect changes. While doing a setTimeout works, it's kind of a hack compared to actually notifying Angular about your intent.
Fourth change: Similar to your form initialization, you had another situation that would cause changed after checked errors when removing the last item from the list and inserting a new (invalid) subform:
removeItem(i: number): void { if (this.steps.length === 1) { this.steps.removeAt(i, { emitEvent: false }); this.steps.push(new FormControl()); this.changeDetectorRef.detectChanges(); } else { this.steps.removeAt(i); } }
Hope that helps.
Hi, iam using express-graphql server on GraphQL end and I have added nginx config file as well as how we are using socket below, it is not complete code and hope it helps
Add a class for hover on animationend.
onAnimationEnd
, isAniationEnded
is set to "true", triggering "className" to apply [
hover:bg-pink-700 hover:text-white p-8]
classes. (using Tailwind CSS... but you can use your own classes there.)
export default function Home() { const [isAnimationEnded, setIsAnimationEnded] = useState(false);
const animationEnded = () => setIsAnimationEnded(true);
useEffect(() => { console.info('animation ended!', isAnimationEnded); }, [isAnimationEnded]);
return ( <div className={styles.container}> <Head> <title>Create Next App</title> </Head>
<main>
<h1
className={cn(styles['start-animation'], 'font-serif text-5xl', {
[hover:bg-pink-700 hover:text-white p-8
]: isAnimationEnded
})}
onAnimationEnd={animationEnded}
>
Hello
</h1>
</main>
</div>
);
}
Working demo: https://stackblitz.com/edit/on-animationend?file=postcss.config.js
https://stackblitz.com/edit/angular-8-template-form-ap9x77?file=src%2Fapp%2Fnode.component.ts
I forked your stackblitz, made some changes and think I achieved what you are looking for. Feel free to ask if there's something you don't understand in my code.
Hijacking top comment to share this thing I whipped together...
Note: output appears in the StackBlitz console. The console must be open or you will only see a blank page.
Note^2: Prices shown are at close on the date listed, and "the Market" portion of calculating Beta is based off indices like $TQQQ or $SPY.
Example: https://i.imgur.com/ihd3kF6.png
Be warned I am no math whiz and just tossed this together to try and see for myself. All the formulas at least naively appear to work as designed, so I sort of trust the numbers.
I tried to lay out the code so even non-techy apes would be able to enter their own values and see what's up.
This is mostly incorrect.
When you use the async pipe in a template, Angular handles subscribe and unsubscribe behind the scenes for you. When you manually call subscribe() in a component, that subscription exists until either the observable completes or until unsubscribe() is called. Lingering "hot" subscriptions can prevent lazy loaded modules from being unloaded, and cause unexpected behavior if they fire events after the component was supposed to have been disposed of.
It's such a common problem that some have become adamant that you should never call subscribe() at all -- they don't trust themselves or others to remember to unsubscribe. I'm more practical than that, but when I perform code reviews it is the first thing I check for in an intermediate Angular developers' code.
I have a StackBlitz that I often use to explain this to colleagues. Perhaps it will help you as well.
I forked your StackBlitz and got it working for you. Let me know here if you have questions, as it might help others out.
Dont worry about this. Just make sure you use some kind of virtual scroll to avoid a huge DOM. Here a example i created some time ago.
Does this not do what you want?
https://stackblitz.com/edit/angular-ivy-f9iywa
​
Note, I threw this together quickly. People are likely to correctly pick nits over best practices.
yes you can do
<button [disabled]="isSomethingExecuting()"></buton>
And it will disable the button depending on the value the function 'isSomethingExecuting' returns.
This is an example from Google on 2-way data-binding
https://stackblitz.com/angular/yjjjblqbkkqv?file=src%2Fapp%2Fapp.component.ts
This will be more informative than any 1 reddit comment: https://angular.io/guide/two-way-binding
For having the same result in multiple components (without making multiple requests to your server multiple times), you must have your data available in one single point of truth, and always read/update from that.
For this, I recommend the use of BehaviorSubject.
I created a detailed Stackblitz for you to understand it.
It's very hard to understand whats wrong by only reading the code you posted. I can't tell, for example, what getallAffectation() doest or returns.
If you create a stackblinkz it would be easier for us to help you.
you know what, my mistake, since you're dealing with multiple files and links between them, i think stackblitz may have been a better testing grounds for sharing
anyways, from what i can see, the way those links are handled is controlled by this javascript:
$(document).ready(function(){ // Handle click on paging links $('.tm-paging-link').click(function(e){ e.preventDefault();
var page = $(this).text().toLowerCase(); $('.tm-gallery-page').addClass('hidden'); $('#tm-gallery-page-' + page).removeClass('hidden'); $('.tm-paging-link').removeClass('active'); $(this).addClass("active"); }); });
you'll need to study this javascript to determine how to preserve the navigation
it works by hiding/showing divs .tm-gallery-page
which each correspond to one of the links
the code is actually pretty hinky. it lowercases the button's text and then finds the div with the matching class name
You can also implement a simple push-based (reactive) architecture yourself using plain RxJS: https://medium.com/@thomasburlesonIA/push-based-architectures-with-rxjs-81b327d7c32d#112f https://stackblitz.com/edit/facades-with-rxjs-only?file=src%2Fapp%2Fuser.facade.ts
The final solution, in case anyone finds this later:
https://stackblitz.com/edit/angular-ukcfkk?file=src%2Fapp%2Fservice%2Ffetcher.service.ts
You can either add some options to your typescript configuration like here: https://stackblitz.com/edit/json-import-example
or you can make a get request to it using http service like the angular tutorial shows you here https://angular.io/guide/http#requesting-data-from-server
Use a view provider. That way you don't even need to pass the form as an input. You can pass this information via the component decorator. (Template driven)
viewProviders: [ { provide: ControlContainer, useExisting: NgForm } ]
This way you can have an NgForm in the parent component, and you don't need to provide any further information to the child component, as long as it's a child node of the form tag. This way you can validate in your child components however you want, and on submit, all data will be available in the parent, via the form's value.
Here is a working example:
https://stackblitz.com/edit/angular-ua5xcz?file=app%2Faddress.component.ts
It takes 1 single line of code to work.
I've seen the scenario /u/OgFinish has originally asked about enough at work and offline to where I've published an example to refer to in the future.
https://github.com/METACEO/example-angular-toast-service
I've tried to prove the scenario further by dynamically creating a toast component through a toast service, so that the consuming component (app.component.ts) does not even know who or what the other component is, but just that the toast service is handling everything.
Stackblitz isn't working with my Angular 8 project, but I could use some help with the CSS of the toast component. :)
I don't think this is right. I setup an example on StackBlitz with a Default change detection AppComponent with 2 children: one OnPush and one Default. All 3 components run an interval and update a counter. The Default change detection child's template is updated, but the OnPush one isn't.
Here's the StackBlitz: https://stackblitz.com/edit/angular-cmi6gd. Am I misunderstanding the results?
The codepen via Mozilla's docs wasn't working for me, so I made a very small Angular app via stackblitz that works for me (using both Mozilla Firefox 68 and Chromium 73) and code is some-what like Mozilla's example:
I'm looking forward to showing this API to some colleagues and clients!.. very cool, and native! I always thought you had to download a browser extension to get this working!
This isn't what you want exactly, but may be helpful. I'm using a second property called "icon". I don't think you'll get the behavior you want without making an icon font like font-awesome.
<svg class="svg-icon" [icon]="webcamIconClass"></svg>
I will first answer you question, and later I will propose a different solution with reasons why.
You can use innerHTML directive to display any arbitrary HTML. Angular will also sanitize the value which is passed to innerHTML directive. div will pass sanitization, but canvas will not. If you want to add canvas, you will have to bypass the sanitizer. Working example: https://stackblitz.com/edit/angular-syaurz
But in order to draw on canvas you will need a reference to the DOM canvas element, and in this example you can not use angular's ViewChild like you usually would to get the reference. You could query it, but that kinda defeats the purpose of using a framework in the first place.
If you want to render different things depending on some conditions, you should define what the possible HTML content is and make all case into separate components. Then you can add ngIfs or switchCases to the template to render correct components.
Basically anything that you render using innerHTML you should consider as static (non-interactive) content. I would not call canvas a static kind of content, so you really want to have a separate component with canvas in its template and a proper reference to the DOM elements which you can use for drawing.
There are some more methods for inserting HTML. Without knowing more details about your use-case it is hard to say which method is the best. You could even look into using ngComponentOutlet structural directive.
Also note that if you are drawing many elements using canvas, you should use 1 canvas which will render N element, and not N canvases which render 1 element each.
I thought you wanted to be able to display the detail outside of the table itself?
Can you provide a simple text mock-up of what you are trying to achieve? It will help to suggest the appropriate HTML structure. Until then I am going to assume this is an example of what you are after...
Are you replying to my StackBlitz, cause that looks like a lot like the code I wrote for that example? Reply might've gone wrong then.
​
Anyway, let me try that!
​
Tried it in a stackblitz: https://stackblitz.com/edit/angular-ekkccr?file=src/app/app.component.ts
No result... Do you have any better luck? Maybe I misunderstood what you were trying to do?
I'm sorry, I was intrigued by your answer. Having plenty of experience with both RxJS and Angular, I didn't see how this would work.
​
I made a StackBlitz to show my attempt: https://stackblitz.com/edit/angular-ksmsp7
​
Could you show how you would approach this problem using this solution? It sounds like an excellent solution if it would work this way honestly.
​
(Note: the `merge` was my attempt at managing to hold 1 Observable to pass to the `| async` pipe, if I overcomplicated things then even better!)
Input passes something from a parent to a child. It's either a primitive value or a reference to an object.
If you change either of those in the child, parent will not be modified.
BUT, if you just change the value (property) of an object passed (and not change it's reference), the parent object WILL be modified.
https://stackblitz.com/edit/angular-atnkxm?file=src%2Fapp%2Fapp.component.html
You may be surprised to find that to make the native table match look like a Material Design table, it only requires a minor amount of styles. See this stackblitz for a replication of the CSS you need: https://stackblitz.com/edit/angular-fvfbtc?file=src%2Fapp%2Fapp.component.css
The issue is that Angular isn't aware of that event listener. You can use (window:resize)="resize()"
in the template instead. Here is a demo.
In general, looking for an "Angular way" of doing things will result in simpler code.
This is the closest I could get, but it comes with problems
https://stackblitz.com/edit/angular-bakxpm?file=src%2Fapp%2Fpercent.directive.ts
Did example of simplified app structure here : https://stackblitz.com/edit/angular-nf5epp
Not sure we still have action @inputs, but you can use it if you show some fields on 'create' but hide on 'edit' or something like that
edit: also we have 'admin' application used to watch/approve/reject user's documents so we simply copy-pasted (not best practice, but deadlines/management/etc.. :) ) shared modules (PaymentOrderSharedModule) from client app to admin, wrapped them with another smart components and it's done: admin app ready
There are a couple of asterisks in the post here which are bolding the text and a slash in front of the *ngFor
, are they included in your code?
When I enter what you posted here (minus the asterisks in the object and the slash in front of the *ngFor
) on a new project on Stackblitz, I get exactly what you're looking for: https://stackblitz.com/edit/angular-fhxcp2
There is also StackBlitz which is basically an online visual studio code. You can also instantly start coding any of your GitHub project as it can integrate with that. Hope that helps
I have create small grid app that might be help you. This is stackblitz demo app link: https://stackblitz.com/github/DatsGawas/dataGridDemo Also I have committed to git https://github.com/DatsGawas/dataGridDemo
https://stackblitz.com/edit/typescript-a5e4w3?file=index.ts
just cleaned some stuff up a bit. now it will be more clear why it fails when it fails.
I have no idea what you mean by weball and Angular 2 is now old but here is an Angular 6 / Rxjs 6 CRUD app. It should give you a start.
https://stackblitz.com/edit/angular-material-table-with-multi-queries
I made a stackblitz with the little information you provide and I don't know if i am missing something, but i have no no issues displaying the result, if you can provide a better stackblitz with your issue i will be happy help you
Oh ryt, this only makes the behavior of the array consistent. The combo boxes still misbehave. Still I refuse to believe this has anything to do with primitive types.
Edit: Okay fixed.
https://stackblitz.com/edit/angular-material-bcgfnf?file=app%2Fapp.module.ts
I think you're running into issues with primitives (which get passed by value) vs objects/arrays (which get passed by reference).
Check this one out: https://stackblitz.com/edit/angular-material-ht7zej?file=app/app.component.html
Try something like this
const combined$ = combineLatest( a$, b$.pipe(startWith(0)), c$.pipe(startWith(0)), ).pipe(map(([a, b, c]) => a))
> In Angular, I am not sure what the equivalent is...
short answer: it's automatic, and in your case it normally should work
to see the problem i'd need to see the code or example of the code, can you create it here and show us? https://stackblitz.com/
Pretty much everything was wrong (for parametrized selectors), but not surprising, took me a while to figure them out too, you need to understand what Higher Order Functions are, because that's what parametrized selectors are, HOFs.
Your getGameCardSet function is a HOF, that takes color param and returns a function that takes state as param.
here is the corrected version of your code: https://stackblitz.com/edit/angular-parameterized-selectors-jlrm3o
> https://stackblitz.com/github/fiyazbinhasan/Angular-Elements?file=src%2Findex.html
Under the Dependencies node you will find a section to put external resources. Add the following es5 adapter,
https://unpkg.com/@webcomponents/[email protected]/custom-elements-es5-adapter.js
I added it for you. You can give it a try here, https://stackblitz.com/edit/github-qeasdu?file=src/index.html
Regards, Fizz
My only criticism is that there's no stackblitz. I wasn't able to get it to work from directly importing it to stackblitz.
https://stackblitz.com/github/fiyazbinhasan/Angular-Elements?file=src%2Findex.html
I get an error saying:
preview-5fcbbe8b659ca43208c8a.js:1 TypeError: Failed to construct 'HTMLElement': Please use the 'new' operator, this DOM object constructor cannot be called as a function. at NgElementImpl.NgElement as constructor at new NgElementImpl (create-custom-element.ts:137) at new AppModule (app.module.ts:42) at _createClass (ng_module.ts:162) at _createProviderInstance$1 (ng_module.ts:141)
When I try to run your code I get the following error:
Template parse errors: "-" is not allowed in reference names ("ass="dropdown" mat-menu-item [matMenuTriggerFor]="submenu2"> Test 3 </button> </mat-menu> <mat-menu [ERROR ->]#sub-menu2="matMenu" yPosition="above"> <button class="dropdown" mat-menu-item> Submenu Test 2 </butt"): ng:///AppModule/AppComponent.html@3:10
When I fix that by changing all instances of sub-menu
to submenu
the code works fine: https://stackblitz.com/edit/angular-material2-issue-hder1x?file=app/app.component.html
Should still work fine
See https://stackblitz.com/edit/material2-beta11-fdhjbv?file=app%2Fapp.component.html
<md-chip-list> <md-chip #chip="mdChip" (selectionChange)="selectChip($event)" (click)="chip.toggleSelected()"> Test </md-chip> </md-chip-list>
I'm a normal user, just one that knows better.
> there isn't a way to better infer things here - > that's why the types work the way they do now.
Yes there is and there it is.
What about https://play.tailwindcss.com/ ?
Or if you want something closer to a local dev environment, https://stackblitz.com/ . You'd need to set things up yourself, but gives you the freedom to play around without installing on your local machine.
Here is a cleaner way
https://stackblitz.com/edit/angular-y7recw?file=src%2Fapp%2Fapp.component.ts
Still can't figure out about ExpressionChangedAfterItHasBeenCheckedError...
Here is a working correction
https://stackblitz.com/edit/angular-ubfzds?file=src%2Fapp%2Fapp.component.ts
But as my comments says, there's an abuse of Angular lifecycle I think. I'll try implement @mptrmptr recomendation
ID é mais fácil de usar no javascript, porque pode chamar diretamente pela referência do elemento. Eu costumo usar ID pra tudo que for único, como menus, artigos, sessões, rodapé, assim o CSS fica melhor dividido.
Exemplo de como o id pode ser acessado no javascript: https://stackblitz.com/edit/web-platform-pxb6v2?file=index.html
Please use markdown to format your code.
Please post the error message you see in the developer console of your browser
Post the code to Stackblitz or Code Sandbox then post the link in your post, click here: https://stackblitz.com/fork/react
People are more prone to help if they can easily see the error or run the code with a few clicks.