I found a few issues with your pluck. Find my updated version 
here: http://plnkr.co/edit/ld51vlEVm6HzOEPsuS6h?p=preview

Basically I think you are getting the error you posted b/c your app wasn't 
requiring ngRoute.

var MyApp = angular.module("MyApp", ['ngRoute']);

I also had to update a few other things to get it working...for one I 
didn't know how to make a directory in plunker land so I simplified the 
partials down to just view1.html and view2.html in the top level dir. Also 
in the plunker I had to include angular and angular-route.  So be sure you 
have both of those in your index.html file. 



On Wednesday, March 26, 2014 4:19:15 PM UTC-5, Walker Kinne wrote:
>
> Ok so I created a Plunk. The link is here: 
> http://plnkr.co/edit/B8P92j3MRi3ngg8Opoig?p=preview 
>
> On Wednesday, March 26, 2014 2:28:51 PM UTC-4, Walker Kinne wrote:
>>
>> I am new to Angular JS and I am working with routes. I have a very simple 
>> application, but I am unable to get the route's to work properly. I will 
>> post my code below. Any help would be greatly appreciated. I am getting an 
>> error as soon as the page loads. 
>>
>>
>> index.html: 
>>
>> <!DOCTYPE html>
>>             <html>
>>             <head>
>>                 <title>Week 2</title>
>>                 <script src="
>> https://ajax.googleapis.com/ajax/libs/angularjs/1.2.14/angular.min.js
>> "></script>
>>                 <script src="main.js"></script>
>>                 <script src="dataService.js"></script>
>>                 <script src="//
>> ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
>>                 <link rel="stylesheet" href="main.css">
>>             
>>             </head>
>>             <body ng-app="MyApp">
>>
>>             <div>
>>             
>>             <div data-ng-view=""></div>
>>             
>>
>>             </div>
>>
>>             
>>             
>>             </body>
>>             </html>
>>
>> main.js: 
>>
>>             /**
>>             * Created by Walker on 3/4/14.
>>             */
>>             
>>             var MyApp = angular.module("MyApp", []);
>>
>>             MyApp.config(function($routeProvider){
>>
>>                 $routeProvider
>>                     .when('/',
>>                     {
>>                         controller: 'AddEmployee',
>>                         templateUrl: '/Partials/View2.html'
>>                     })
>>                     .when('/view2',
>>                     {
>>                         controller: 'AddEmployee',
>>                         templateUrl: '/Partials/View1.html'
>>                     })
>>                     .otherwise({ redirectTo: '/'});
>>
>>
>>             });
>>
>>                 MyApp.controller("AddEmployee", function ($scope, 
>> dataService){
>>             
>>
>>             
>>             $scope.userName;
>>             
>>             $scope.nameArray = dataService.getNames();
>>             
>>             
>>             
>>             $scope.addName = function(){
>>             
>>             
>>             dataService.addNames($scope.userName, $scope.address, 
>> $scope.number);
>>             
>>             $scope.userName = '';
>>             $scope.address = '';
>>             $scope.number = '';
>>             
>>             };
>>             
>>             
>>             $scope.deleteName = function(deletedName){
>>             
>>             dataService.removeName(deletedName);        
>>             };
>>             
>>             
>>             
>>             
>>             
>>             
>>             });
>>
>>
>> dataservice.js
>>
>>             MyApp.service("dataService", function(){
>>                 
>>                 
>>                 
>>                 
>>                 var namesArray = [];
>>
>>
>>                 function Employee(name, addr, phoneNumber){
>>                     this.name = name;
>>                     this.addr = addr;
>>                     this.phoneNumber = phoneNumber;
>>
>>
>>
>>                 };
>>
>>                 
>>                 this.getNames = function(){
>>                 
>>                     var str = localStorage.getItem("NameLS");
>>                     namesArray = JSON.parse(str) || namesArray;
>>                     
>>                     return namesArray;
>>                     console.log(namesArray);
>>                     
>>                 };
>>                 
>>                 this.addNames = function(pName, pAddress, pNumber){
>>                     
>>
>>
>>                     var test = new Employee(pName, pAddress, pNumber);
>>
>>                     console.log(test)
>>
>>                     namesArray.push(test);
>>
>>                     console.log(namesArray);
>>
>>                     
>>                     var str = JSON.stringify(namesArray);
>>                     localStorage.setItem("NameLS", str);
>>                     
>>                 };
>>                 
>>                 this.removeName = function(pName){
>>                     
>>                     namesArray.splice(namesArray.indexOf(pName), 1);
>>                     var str = JSON.stringify(namesArray);
>>                     localStorage.setItem("NameLS", str);
>>                     
>>                 }
>>                 
>>             });
>>             
>>             
>>             
>>             
>>             
>>             
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to