title: Angularjs: ng-class and form validation
body: <p>I am a newer angular user and i trying to do validation over a form. I found an example here:
  <a href="http://plnkr.co/edit/gLDFaf?p=preview" rel="nofollow noreferrer">http://plnkr.co/edit/gLDFaf?p=preview</a></p>
  
  <p>It's exactly what i want...so what my problem :)
  I don't understand why validation (red border) doesn't work if i add "use strict"; at the top of script.js</p>
  
  <pre><code>"use strict";  // &lt;-- validation doesn't work if removed
  module = angular.module('app', []);
  
  module.controller('NewUserController', function($scope) {
    $scope.save = function() {
      if ($scope.userForm.$valid) {
        alert('User saved');
        $scope.reset();
      } else {
        alert("There are invalid fields");
      }
    };
  
    $scope.reset = function() {
      $scope.user = { name: '', email: '' };
    }
  });
  </code></pre>
  
  <p>And the view:</p>
  
  <pre><code> &lt;body ng-app="app" ng-controller="NewUserController"&gt;
      &lt;h1&gt;Add New User&lt;/h1&gt;
      &lt;form name="userForm" novalidate&gt;
        &lt;div class="form-group" ng-class="{ 'has-error': userForm.name.$invalid }" &gt;
          &lt;label class="control-label"&gt;Name&lt;/label&gt;
          &lt;input type="text" class="form-control" name="name" ng-model="user.name" required placeholder="Name" /&gt;
        &lt;/div&gt;
        &lt;div class="form-group" ng-class="{ 'has-error': userForm.email.$invalid }" &gt;
          &lt;label class="control-label"&gt;Email&lt;/label&gt;
          &lt;input type="email" class="form-control" name="email" ng-model="user.email" required placeholder="Email" /&gt;
        &lt;/div&gt;
        &lt;button class="btn btn-primary" ng-click="save()"&gt;Add User&lt;/button&gt;
        &lt;button class="btn btn-link" ng-click="reset()"&gt;Reset&lt;/button&gt;
      &lt;/form&gt;
    &lt;/body&gt;
  </code></pre>
  
  <p>Can someone explain this?</p>