You can easily use w3.css style sheet together with AngularJS. This chapter demonstrates how.
To include W3.CSS in your AngularJS application, add the following line to the head of your document:
If you want to study W3.CSS Tutorial, visit our W3.CSS Tutorial.
Below is a complete HTML example, with all AngularJS directives and W3.CSS classes explained.
AngularJS Directive | Description |
---|---|
<body ng-app> | Defines an application for the <body> element |
<body ng-controller> | Defines a controller for the <body> element |
<tr ng-repeat> | Repeats the <tr> element for each user in users |
<button ng-click> | Invoke the function editUser() when the <button> is clicked |
<h3 ng-show> | Show the <h3> element if edit = true |
<h3 ng-hide> | Hide the form if hideform = true , and hide the <h3> if edit = true |
<input ng-model> | Bind the <input> element to the application |
<button ng-disabled> | Disables the <button> if error or incomplete = true |
Element | Class | Defines |
---|---|---|
<div> | w3-container | A content container |
<table> | w3-table | A table |
<table> | w3-bordered | A bordered table |
<table> | w3-striped | A striped table |
<button> | w3-btn | A button |
<button> | w3-green | A green button |
<button> | w3-ripple | A ripple effect when you click the button |
<input> | w3-input | An input field |
<input> | w3-border | A border on the input field |
userCtrl
Source CodeScope Properties | Used for |
---|---|
$scope.fName | Model variable (user first name) |
$scope.lName | Model variable (user last name) |
$scope.passw1 | Model variable (user password 1) |
$scope.passw2 | Model variable (user password 2) |
$scope.users | Model variable (array of users) |
$scope.edit | Set to true when user clicks on 'Create user' |
$scope.hideform | Set to false when user clicks on 'Edit' or 'Create user' |
$scope.error | Set to true if passw1 not equal passw2 |
$scope.incomplete | Set to true if any field is empty (length = 0) |
$scope.editUser | Sets model variables |
$scope.$watch | Watches model variables |
$scope.test | Tests model variables for errors and completeness |