javascript - angular.element.addClass wired -


i'm learning tutorial egghead angular.element , following create testing scripts. angular.element's behaviour different tutorial. toggleclass or addclass add "class" both "input" , "div". see below script , picture. bug? or i'm missing something?

<html ng-app="app">   <head lang="en">     <meta charset="utf-8" />     <title>debug</title>     <link rel="stylesheet" href="/css/foundation.css" />   </head>   <body>     <dumb-password></dumb-password>     <script src="/js/angular-1.2.0rc1/angular.js"></script>     <script>     angular.module('app', [])     .directive('dumbpassword', function () {       return {         restrict: 'e',         replace: true,         template: '<div><input type="text" ng-model="model.input"><div>{{model.input}}</div></div>',         link: function (scope, element) {           scope.$watch('model.input', function (value) {             if (value === 'password') {               element.children(1).toggleclass('alert-box alert')             } else {               element.children(1).removeclass('alert-box alert')             }           })         }       }     })     </script>   </body> </html> 

result

in function:

link: function (scope, element) 

element container div, , element.children(1) not accept selector children. angular.element. try:

element.children().eq(1) 

or

element.find("div") 

Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -