javascript - Error Argument is not defined -


i'm testing angularjs , when try visualize example browser's console shows me this:

error: argument 'maincontroller mainctrl' not function, got undefined     @ error (native)     @ bb  

i have 2 files in project

index.html

   <!doctype html> <html ng-app="my-app">   <head>     <title>angular controllers</title>     <meta name="viewport" content="width=device-width, initial-scale=1">     <!-- angularjs , jquery include.  -->     <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>     <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.8/angular.min.js"></script>     <!-- latest compiled , minified css -->     <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"></link>     <!-- optional theme -->     <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css"></link>     <!-- latest compiled , minified javascript -->     <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>   </head>    <body>      <div class="container">       <form name="particleform" ng-controller="maincontroller mainctrl" ng-submit="mainctrl.adddata()">         {{ mainctrl.data.email }}         <div class="form-group">           <label for="text" class="col-sm-2 col-sm-offset-2">e-mail</label>         </div>          <div class="col-sm-10">           <input type="text" name="text" class="form-control" ng-model="mainctrl.data.email" placeholder="enter e-mail..."></input>         </div>       </form>     </div>      <script src="app.js"></script>   </body> </html> 

app.js

(function (){   var app = angular.module('my-app', []);    var list = [];    app.controller ('maincontroller', function (){     this.data = {};      this.adddata = function (){       list.push (this.data);        list.data = {};     };   }); })(); 

i want show put on input field.

the foocontroller fooctrl syntax available starting angularjs 1.1.5 (see this). you're using 1.0.8.


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

Kivy: Swiping (Carousel & ScreenManager) -