0
votes

I'm trying out the form example that you can find here: https://docs.angularjs.org/guide/forms I cannot make it work in my own page. It ends up with this error:

TypeError: undefined is not a function at pre (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.min.js:178:192) at J (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.min.js:53:156) at f (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.min.js:46:399) at J (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.min.js:53:286) at f (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.min.js:46:399) at f (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.min.js:46:416) at https://ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.min.js:46:67 at https://ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.min.js:18:67 at h.$eval (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.min.js:108:482) at h.$apply (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.min.js:109:235)

I cannot figure out why; see below for my index.html page source:

<head>
    <!-- JQUERY -->
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>      

    <!-- Angular -->
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.min.js"></script>
    <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.3/angular-sanitize.js"></script>
</head>
<body ng-app>
    <div ng-controller="Controller">
      <form novalidate class="simple-form">
        Name: <input type="text" ng-model="user.name" /><br />
        E-mail: <input type="email" ng-model="user.email" /><br />
        Gender: <input type="radio" ng-model="user.gender" value="male" />male
        <input type="radio" ng-model="user.gender" value="female" />female<br />
        <button ng-click="reset()">RESET</button>
        <button ng-click="update(user)">SAVE</button>
      </form>
      <pre>form = {{user | json}}</pre>
      <pre>master = {{master | json}}</pre>
    </div>
</body>
<script>
  function Controller($scope) {
    $scope.master = {};

    $scope.update = function(user) {
      $scope.master = angular.copy(user);
    };

    $scope.reset = function() {
      $scope.user = angular.copy($scope.master);
    };

    $scope.reset();
  }

1

1 Answers

2
votes

According to angular's FAQ: Does Angular use the jQuery library?:

Due to a change to use on()/off() rather than bind()/unbind(), Angular 1.2 only operates with jQuery 1.7.1 or above.

Here is an example of your code working with the 1.7.2 version of jQuery: http://plnkr.co/edit/DFEMno6d7ovbXbgoNvhw?p=preview