dependency injection - AngularJs service not injected in controller -


i having trouble simple inject basic service controller , despite reading documentation , other question don't see mistake i'm making.

here's simplified code:

angular.module ('travelapp', ['ui.bootstrap', 'ngroute']) 

//controllers

.controller('searchcontroller', ['$scope','myparams', function ($scope,ngroute,myparams){     $scope.place = myparams.place;    $scope.$watch('place', function(){       myparams.place = $scope.place;     });      $scope.bind = function(){         console.log(myparams.getplace);     }; }]) 

//services

.service('myparams', function(){     this.place = 'start'; }); 

//my html

<div class="container" ng-app="travelapp">     <div class="jumbotron" id="searchpage" ng-controller="place">     <div>         <h3>start here</h3>         <input type="text" class="form-control" id="searchbar" ng-model="place">         <a type="button" class="btn btn-default" ng-click="bind()">bind data</a>     </div> </div> 

i have tried number of things in past few hours keep getting

"typeerror: cannot set property 'place' of undefined"

it seems service no available inside controller, don't know if has routing doubt so.

can please point me in right direction?

here plunker

your dependencies must match if use array syntax. remove ngroute controller's arguments.

.controller('searchcontroller', ['$scope','myparams', function ($scope, myparams){ 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -