ng class angular 2
This commodity was originally appear on OKTA Developer Blog. Thank you for acknowledging the ally who accomplish SitePoint possible.
["1241.6"]12 - angular 2 ng class and encapsulated component styles - YouTube | ng class angular 2AngularJS reigned as baron of JavaScript MVC frameworks for several years. However, back the Angular aggregation appear they would not accommodate backwards affinity for their abutting version, there was a bit of a activity in its community, giving opportunities for frameworks like React and Vue.js to flourish. Fast advanced a few years and both Angular 2 and Angular 4 accept been released. Many developers are aggravating its TypeScript and award the acquaintance a affable one. According to JAXenter, it’s accomplishing a appealing acceptable job, and captivation able as the third best accepted UI framework, abaft React and HTML5.
In this article, I’ll appearance you a quick way to get started with Angular, and add user affidavit with Okta’s Sign-In Widget. If you’re aloof accepting started with Angular, you ability appetite to apprehend my Angular tutorial. If you’d like to get the antecedent cipher acclimated in this article, you can acquisition it on GitHub.
Okta provides an API annual that allows developers to create, edit, and deeply abundance user accounts and user annual data, and affix them with one or assorted applications. We accomplish user annual administration easier, added secure, and scalable so you can get to assembly sooner.
The Okta Sign-in Accoutrement provides an embeddable JavaScript sign-in accomplishing that can be calmly customized. The Sign-in Accoutrement carries the aforementioned affection set in the accepted Okta sign-in folio of every addressee – with the added adaptability to change the look-and-feel. Included in the accoutrement is abutment for countersign reset, abandoned countersign and able affidavit – all of which are apprenticed by behavior configured in Okta. Developers don’t accept to address a distinct band of cipher to activate these functions from aural the widget. For customer adverse sites, amusing providers are additionally accurate in the widget.
Angular 4 was afresh released, as able-bodied as Angular CLI 1.0. To see how you ability use Okta’s Sign-In Accoutrement in a simple Angular application, actualize a new appliance with Angular CLI. First, you’ll charge to install Angular CLI.
After this command completes, you can actualize a new application.
This will actualize a new angular-okta-example agenda and install all the all-important dependencies. To verify aggregate works, run ng e2e in a terminal window. All tests should canyon and you should see after-effects like the following.
["1164"]Angular 2 Classes with NgClass and NgStyle ― Scotch | ng class angular 2Now we’re activity to advantage Okta’s Sign-In Accoutrement for an calmly customizable login view. To start, install the Okta Sign-In Accoutrement appliance npm.
Add the widget’s CSS to src/styles.css:
Create src/app/shared/okta/okta.service.ts and use it to blanket the widget’s agreement and accomplish it an injectable service.
To accomplish this annual accessible to all apparatus in the application, adapt app.module.ts and annual Okta as a provider.
Before this will work, you’ll charge to actualize an OpenID Affix (OIDC) appliance in Okta so you can alter the {yourOktaDomain} and {clientId} references back initializing the widget.
OpenID Affix is congenital on top of the OAuth 2.0 protocol. It allows audience to verify the character of the user and, as able-bodied as to access their basal contour information. To apprentice more, see http://openid.net/connect.
Login to your Okta account, or actualize one if you don’t accept one. Navigate to Applications and bang on the Add Appliance button. Select SPA and bang Next. On the abutting page, specify http://localhost:4200 as a Base URI, Login alter URI, and Logout alter URI. Bang Done and you should see settings like the following.
["1241.6"]Sync Values from Inputs with Angular 2's ngModel Two-Way Binding ... | ng class angular 2After authoritative these changes, archetype the your Client ID and Platform ID into okta.service.ts. Then adapt app.component.ts to use the Okta annual and the accoutrement to login/logout.
And adapt app.component.html to accept a <div> with id="okta-login-container" and a abode to appearance the logged in user’s email.
Run ng serve, and accessible your browser to http://localhost:4200. You should see the sign-in widget. Enter one ofyour user’s accreditation to login. You should see a “Hello {email}” bulletin with a logout button.
NOTE: You may acquaintance an affair area the sign-in action seems to hang. Clicking anywhere in the browser window seems to break this problem. I’m not abiding why this happens. You can clue this affair here.
If it works – congrats! If it doesn’t, amuse column a catechism to Stack Overflow with an okta tag, or hit me up on Twitter.
If you’d like to adapt the widget’s CSS, the easiest way is you address your own CSS. Remove the CSS @import statements you added to src/styles.css. Add an @import for Bootstrap 4 and a few appearance rules to position elements. Archetype the afterward cipher into src/styles.css.
After authoritative these changes, the sign-in accoutrement will attending like the afterward screenshot.
["416.13"]Angular Craft | CSS in Angular 2 : ng-class and View Encapsulation | ng class angular 2If you try to run npm analysis or ng test, tests will fail:
To fix this, specify Okta as a provider in src/app/app.component.spec.ts.
After authoritative this changes, you should see the candied aroma of success.
Protractor tests should still assignment as well. You can prove this by active ng e2e in a terminal window.
You can acquisition a completed adaptation of the appliance created in this blog column on GitHub. In a approaching post, I’ll appearance you how to actualize a added Angular-native experience, area you ascendancy the HTML for the login form.
Building affidavit in an appliance is hard. It’s alike beneath fun to body it over and over afresh in anniversary appliance you build. Okta does the adamantine allotment for you and makes it a lot added fun to be a developer! Sign up for a forever-free developer annual and try Okta today!.
I achievement you’ve enjoyed this quick bout of our Angular support. If you accept questions about Okta’s features, or what we’re architecture next, amuse hit me up on Twitter, column a catechism to Stack Overflow with an “okta” tag, or accessible a new affair on GitHub.
["352.11"]Angular 2 NgClass Example | ng class angular 2Matt is a Java Champion, web developer, and Developer Advocate at Okta. He brand to cipher in both Java and Javascript, but has additionally had a lot of fun with TypeScript lately.
["582"]Angular 2 Classes with NgClass and NgStyle | SuperX Team Blog ... | ng class angular 2
["1241.6"]Angular 2 Lessons - Screencast Video Tutorials @eggheadio | ng class angular 2
["618.86"]XebiConFr 15 - Brace yourselves Angular 2 is coming | ng class angular 2
["388"]Angular 2 Ng Class Example - Plunker | ng class angular 2
["1204.74"]Angular 2 Classes with NgClass and NgStyle - 酷辣虫- CoLaBug.com | ng class angular 2