diff --git a/index.html b/index.html index fde1d5a..f3c69e5 100644 --- a/index.html +++ b/index.html @@ -76,7 +76,9 @@
The ui-validate directive makes it very easy to use any function as a validation function for input elements using ngModel.
AngularJS comes with several built-in validation mechanism for input fields (ngRequired, ngPattern etc.) but using an arbitrary validation function requires creation of custom formatters and / or parsers. The ui-validate directive makes it easy to use any function(s) defined in scope as a validator function(s).
-Just add the 'ui-validate' directive to your input field.
-2 types of syntax are supported: -
ui-validate="validateFoo"ui-validate="{foo : validateFoo, bar : validateBar}"The ui-validate directive makes it very easy to use any function as a validation function for input elements using ngModel.
AngularJS comes with several built-in validation mechanism for input fields (ngRequired, ngPattern etc.) but using an arbitrary validation function requires creation of custom formatters and / or parsers. The ui-validate directive makes it easy to use any function(s) defined in scope as a validator function(s).
+Just add the 'ui-validate' directive to your input field.
+ui-validate="'method($value)'"$value variable.ui-validate="'validateFoo($value)'"ui-validate="{foo : 'validateFoo($value)', bar : 'validateBar($value)'}"ui-validate-watch can be used to watch another model and updates ui-validate whenever the passed model changes.
+ ui-validate-watch="'anotherModel'"ui-validate-watch="{foo: 'anotherModel'}"
-<input ng-model="email" ui-validate='{blacklist : notBlackListed}'>
+<input ng-model="email" ui-validate="{blacklist : 'notBlackListed($value)'}">
<span ng-show='form.email.$error.blacklist'>This e-mail is black-listed!</span>
- and in a controller:
+ and in a controller:
function ValidateCtrl($scope) {
- $scope.blackList = ['bad@domain.com','verybad@domain.com'];
- $scope.notBlackListed = function(value) {
- return $scope.blackList.indexOf(value) === -1;
- };
+ $scope.blackList = ['bad@domain.com','verybad@domain.com'];
+ $scope.notBlackListed = function(value) {
+ return $scope.blackList.indexOf(value) === -1;
+ };
}
-
- Drag and drop the parents and children
+You're not fit to be a mother!
+Parents: {{parents|json}}
+
+<script>
+$scope.parents = [
+ { name: 'Anna',
+ children: ['Alvin', 'Becky' ,'Charlie'] },
+ { name: 'Barney',
+ children: ['Dorothy', 'Eric'] },
+ { name: 'Chris',
+ children: ['Frank', 'Gary', 'Henry'] }
+];
+</script>
+
+<ul ui-sortable ng-model="parents">
+ <li ng-repeat="parent in parents">
+ <h3>{{parent.name}}</h3>
+ <ul class="children"
+ ui-sortable="{connectWith:'.children'}"
+ ng-model="parent.children">
+ <li ng-repeat="child in parent.children">
+ {{child}}
+ </li>
+ </ul>
+ </li>
+</ul>
+ Static Items: {{items|json}}
+ +<script> +$scope.items = ['One', 'Two', 'Three']; +</script> + +<ul ng-model="items" ui-sortable> + <li>First</li> + <li>Second</li> + <li>Third</li> +</ul>+
Route Matching Magic. It matches your routes ... magically!
+Clicking "Make Active" will reload the page. Pay attention to the routes.
+It would be nice if your app knew what the address path was and acted accordingly, right? Right.
+$uiRoute.
+ <a ui-route="/page" ng-class="{active: $uiRoute}">link</a>ui-route as an attribute with value supports the following:
+ <a ui-route="/page"><a ui-route="/page/[0-9]*"><a ui-route="/page/{{ sample }}"><a ui-route="/page/{{ sample }}/[0-9]*">ui-route with ng-href attribute:
+ <a ui-route ng-href="/page"><a ui-route ng-href="/page/{{ sample }}">ui-route with href attribute:
+ <a ui-route ng-href="/page">+<ul> + <li ui-route="#/route-1">Route 1 + <strong ui-if="$uiRoute">IS</strong> + <strong ui-if="!$uiRoute">is NOT</strong> active. + </li> + <li ui-route="#/route-2">Route 2 + <strong ui-if="$uiRoute">IS</strong> + <strong ui-if="!$uiRoute">is NOT</strong> active. + </li> + <li ui-route="#/route-3">Route 3 + <strong ui-if="$uiRoute">IS</strong> + <strong ui-if="!$uiRoute">is NOT</strong> active. + </li> +</ul> ++