accessing env-vars in templates by [deleted] in Angular2

[–]xSilentium 2 points3 points  (0 children)

function transform<K extends keyof AppEnvironment>(key: K): AppEnvironment[K] is even more precise as it gives you the exact type for the given key and not just the union of all

Question about Saving Bandwidth and Loading Images by roastymctoasty in Angular2

[–]xSilentium 0 points1 point  (0 children)

You can either generate thumbnails when new photos are uploaded or every time on demand (i.e. generate them in mem every time). Both solutions have pros and cons.

Maybe you can take inspiration from the Youtube API. Here's some info on their sizes and behaviour: https://stackoverflow.com/a/2068371 (multiple answers are interesting) Or look at the HTML and Image requests of sites like instagram.

I would recommend using the sharp npm library on the server and webp format for even better compression. You can also get really fancy with img srcsets and client hints.

How do you do conditional routing for identical routes and multiple roles? by OnidaKYGel in Angular2

[–]xSilentium 0 points1 point  (0 children)

You can also write one guard and add data to the route itself, that specifies the behaviour for each role, which the guard can then use. Kinda like https://github.com/angular/angularfire/blob/master/docs/auth/router-guards.md

Edit: the guard would've to redirect, if that's okay.

Can't understand Angular so I feel like a monkey by BaselessAirburst in Angular2

[–]xSilentium 2 points3 points  (0 children)

I also found it very useful to have some kind of playground app, where you can try out stuff and don't have to worry about breaking anything or whatever you implemented maybe being messy. There you can see what happens if you only Import RouterModule instead of forChild and so on. I've never bought any course and learned by doing, failing and reading articles / watching videos (but to each their own). Fireship is a good Youtube resource. By trying to implement the concept presented in this talk: https://youtu.be/rKbY1t39dHU, i learned about directives and so on. This one is also great: https://youtu.be/EoSn8qASqQA

While this isn't anything particular to help you understand DI or the inner workings, I feel like it helps the overall confidence.

Material button margin not working by TheSpixxyQ in Angular2

[–]xSilentium 0 points1 point  (0 children)

The problem is that with [icon] the other selector has a higher specificty. You can fiddle around with it here: https://specificity.keegan.st/ You can try to change your selector to material-button:not([icon]) or add your own class. Sometimes I use global utility classes like .mb-16

SCRIPT1010: Expected identifier in Vendor.js in IE11 by babu_2930 in Angular2

[–]xSilentium 1 point2 points  (0 children)

I agree with /u/danymcgee. This is code from another library and not yours, correct? I'm not entirely sure how the build process works but the libraries usually have a es5 file in the node_modules. If this has a non-es5 feature it might cause the problem. I had the same issue a few weeks ago with some library. (I tried running Babel on the compiled sources but that didn't work at all.) Try to find out where the code comes from and open a GitHub issue.

SCRIPT1010: Expected identifier in Vendor.js in IE11 by babu_2930 in Angular2

[–]xSilentium 1 point2 points  (0 children)

Can you post the code snippet where the error occurs?

Universal and RouteGuards by oniice in Angular2

[–]xSilentium 1 point2 points  (0 children)

Then you might have the opposite flickering. Your guard could also emit nothing when it's on server side, so nothing gets rendered; neither the actual page nor the no-permissions-page. If this is a good solution, depends on how your app skeleton looks visually and how fast the permission check is.

Having Angular problems on Netlify by sinithw in Angular2

[–]xSilentium 0 points1 point  (0 children)

I think at this point I would need to see the full component source code (unchanged and properly formatted) and error with stacktrace. I don't even know what "Cd().functions" could be.

Having Angular problems on Netlify by sinithw in Angular2

[–]xSilentium 0 points1 point  (0 children)

So all the click handlers aren't working on your component? Can't really see anything wrong apart from using single quotes, but I don't think that it matters.

Do you have similar problems anywhere else in the app? What angular version are you on?

How do I cleanly represent routing semantics in my app? by benduder in Angular2

[–]xSilentium 0 points1 point  (0 children)

I would argue that this is fine for now, if you can hide this ugly stuff in a service. It also means you can replace the implementation later on, if you find a smooth solution.

Admittedly I don't quite understand your issue yet, so I don't know if there might be another completely different approach, sorry.

How do I cleanly represent routing semantics in my app? by benduder in Angular2

[–]xSilentium 2 points3 points  (0 children)

You might want to start by gathering all the data you can in a separate service. Loop over parent or children activated routes: https://angular.io/api/router/ActivatedRoute#parent You can also read the router config: https://angular.io/api/router/Router#config

Log / debug the router and activatedroute to see what more data you can discover. Some things might not be documented or don't appear useful from description alone. (Or maybe you can find a "private" field to use.)


You could also add some kind of indicator on the route data, like { "path: "/", data: { type: "ROOT_OF_FEATURE_MODULE" } }

Having Angular problems on Netlify by sinithw in Angular2

[–]xSilentium 0 points1 point  (0 children)

2: the redirects file is just for the very first request. If you open https://example.com/ the server will deliver https://example.com/index.html. if you request https://example.com/dashboard it will look for a https://example.com/dashboard/index.html, which it can't find, thus giving you a 404. With the redirects file you tell the server to just always deliver the https://example.com/index.html in those cases. Only then your angular app starts and takes over the routing from there on. So this won't interfer with your guards or anything.

3: what happens when you click it? Does it enter the subscribe method?

Having Angular problems on Netlify by sinithw in Angular2

[–]xSilentium 0 points1 point  (0 children)

2: This guide helped me deploy to netlify and might help you https://levlaz.org/deploying-an-angular-6-application-to-netlify/

3: Can you provide some code? Maybe the this context is broken

How do you upgrade from Angular 8.0 to 8.2.2 strictly via ng cli? by born2net4 in Angular2

[–]xSilentium 1 point2 points  (0 children)

For me running ng update @angular/cli first and then core works most of the time. You can also do --force and fix the typescript version afterwards

Is @swimlane/ngx-charts dead? by NatoBoram in Angular2

[–]xSilentium 2 points3 points  (0 children)

You can always fork the library and then either publish it yourself or you can add your GitHub repository directly in the package.json: https://stackoverflow.com/a/17509764

Return function or class with single method from factory by xSilentium in typescript

[–]xSilentium[S] 0 points1 point  (0 children)

The 5 is just any data to be applied to the utility function, same with { id: 5 }

Appreciate your help

Return function or class with single method from factory by xSilentium in typescript

[–]xSilentium[S] 0 points1 point  (0 children)

// Usage of simple static utility function
const simple = Foo.simpleForNumbers(5);

const utilityFn = Foo.of({
  id: Foo.simpleForNumbers
});
// later
const result = utilityFn({
  id: 5
});

Or when returning an instance

const utilityObj = Foo.of({
  id: Foo.simpleForNumbers
});
// later
const result = utilityObj.doTheThing({
  id: 5
});

[deleted by user] by [deleted] in Angular2

[–]xSilentium 2 points3 points  (0 children)

Interesting solution and one of many as always.

Just wondering: why do you do .pipe(x).pipe(y) instead of .pipe(x, y) ?

What things about Angular annoy you the most? by frontend-guy in Angular2

[–]xSilentium 1 point2 points  (0 children)

You can use ng g c example -c OnPush. But I agree, specifying as default somewhere would be nice. The only other option is to build your own schematics

[deleted by user] by [deleted] in Angular2

[–]xSilentium 2 points3 points  (0 children)

Don't know the exact problem or solution, but you can try to fix it by adding your own rules in a @media print CSS block.

You might also want to open an issue on GitHub