The best practice to show or hide the element in Angular
In the past, AngularJS is using "ng-if" to control whether the div is show or hide. That is basic 101. In Angular, the syntax are changed, there are no more "ng-" somethings. Now, that is using somethings more similar with, [hidden]. So you can bind a variable with that to control the visibility of div.
Example:
Code
class="amc_code_even"> |
| ||
|
Angular + Asp.net core identity is not easy, you need some custom claims
In Visual Sutdio 2019, Angular+ .net core identity is nearly done by a single click. But that is not easy if you wish to add extra custom claims. I have tried to used IdentityResource or IProfileService to config the Identity server at Startup.cs. That is not successful. That is easier to build own in this case. Mainly, you need to build login service by yourself.
At this stage, I believe the angular code can be reuse. I just need to config it to use my own login url.
Separating the routes in angular
I don't know why the default .net core angular template all routes in the app.modules.ts like this
Code
RouterModule.forRoot([ | |
{ path: '', component: HomeComponent, pathMatch: 'full' }, | |
{ path: 'counter', component: CounterComponent }, | |
{ path: 'fetch-data', component: FetchDataComponent }, | |
]) |
If you build more modules, then the codes will become quite unmanageable. This is not clean at all.
I suggest a better practice, to create app.routes.ts.
This like:
Code
export class AppRoutes { | |
getRoutes() { | |
return [ | |
{ path: '', component: HomeComponent, pathMatch: 'full' }, | |
{ path: 'counter', component: CounterComponent }, | |
| |
{ path: 'fetch-data', component: FetchDataComponent }, | |
]; | |
} | |
} |
Then in the app.modules.ts, it will import the routes
Code
let appRoutes = new AppRoutes(); | |
RouterModule.forRoot(appRoutes.getRoutes()) |
This approach is more clear
X Bows Keyboard - The unusal but comfortable keyboard
The X-Bows Keyboard started from the Kickstarter a few years ago. It has an unusual keyboard pattern, and it claimed to balance performance and comfort. That is a very attractive slogan. So, I bought one to test it out for USD$125 (Non-LED backlight version).
I took about two weeks shipped from China to Australia. Firstly, I have to admire their customer support very promptly. They answered my question unless than 24 hours. Secondly, their built quality is excellent; the keyboard feels solid. Thirdly, the pattern of the keyboard is quite unusual. It took me three days to adapt. After I get used to the pattern, the typing is fast, very similar to the standard keyboard. Moreover, it is quite ergonomic; it is a natural hand position.
Besides, the wrist rest is very high quality. I cannot find anyone as comfort as like this one
However, there are some downsides. Firstly, you have to very careful to update the firmware. First times, I did that. I "killed" my keyboard. Please do not worry, after I contacted their support team, and they gave me a software to reflash the ROM. Then it works again. Another downside is the keyword switch is Gateron, not cherry MX. I found the typing experience is a bit less comfortable than cherry.
In general, I love this keyboard.
RecyclerView only show one element
There is not listview in more modern Android SDK. The replacement of this is RecyclerView, that is more flexible, you can set the layout manager, such as LinearLayoutManager or GridLayoutManager, even you can build your own. But that is more powerful, then that is harder to use. The first program I built, I found it only shows the first element. Then I found in the layout resource file of list adapter, the root element cannot set the height to be "match_parent", if you set "match_parent", the first element will be occupied the whole list, then no room for another elements. So the solution is to the height to be the fixed value or "wrap_content.