Actually, the best way to solve your problem is if you make a Plunker script. See the description for this mailing list.
On Wednesday, March 26, 2014 11:28:51 AM UTC-7, 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.
