angularjs - Angular.js - Scope join error -
sorry i'm total noob in angular, i'm having problem adding user model todo list app:
http://yeoman.io/codelab/write-app.html
here controller:
'use strict'; angular.module('test3app') .controller('mainctrl', function ($scope, localstorageservice) { var usersinstore = localstorageservice.get('users'); var todosinstore = localstorageservice.get('todos'); $scope.users = usersinstore && usersinstore.split('\n') || []; $scope.todos = todosinstore && todosinstore.split('\n') || []; $scope.$watch('users', function () { localstorageservice.add('users', $scope.users.join('\n')); }, true); $scope.$watch('todos', function () { localstorageservice.add('todos', $scope.todos.join('\n')); }, true); $scope.addtodo = function () { $scope.todos.push($scope.todo); $scope.todo = ''; }; $scope.removetodo = function (index) { $scope.todos.splice(index, 1); }; $scope.adduser = function () { $scope.users.push($scope.users); $scope.users = ''; }; $scope.removeuser = function (index) { $scope.users.splice(index, 1); }; });
i'm getting error on line:
localstorageservice.add('users', $scope.users.join('\n')); typeerror: undefined not function @ object.fn (http://localhost:9000/scripts/controllers/main.js:14:53) @ scope.$digest (http://localhost:9000/bower_components/angular/angular.js:12251:29) @ scope.$apply (http://localhost:9000/bower_components/angular/angular.js:12516:24) @ htmlformelement.<anonymous> (http://localhost:9000/bower_components/angular/angular.js:18626:21) @ htmlformelement.jquery.event.dispatch (http://localhost:9000/bower_components/jquery/dist/jquery.js:4641:9) @ htmlformelement.elemdata.handle (http://localhost:9000/bower_components/jquery/dist/jquery.js:4309:46)
what doing wrong?
Comments
Post a Comment