javascript - Can't load own service into angularjs-script -
so want inlcude own service angular-script. won't find servicename, when set params of script.
i got script(script.js):
(function(){ var app = angular.module("viewer", []); var mainctrl = function($scope, viewthis, $http, $interval, $log){ magic; }; app.controller("maincontroller", mainctrl); }());
and service(viewthis.js):
(function() { var viewthis = function($http) { methods, magic; //there homecoming in method: homecoming $http.get("https://api.github.com/users/" + username); homecoming { method: method }; }; var module = angular.module("viewer"); module.factory("viewthis", viewthis); }());
this html head:
<head> <script src="angular.js"></script> <link href="style.css" rel="stylesheet" /> <script src="script.js"></script> <script src="viewthis.js"></script> </head>
the firefox-developement-tool says in console:
"error: [$injector:unpr] http://errors.angularjs.org/1.2.26/$injector/unpr?p0=githubprovider%20%3c-%20github c/<@file:///z:/angulartut/angular.js:6:443 gc/l.$injector<@file:///z:/angulartut/angular.js:36:196 c@file:///z:/angulartut/angular.js:34:300 gc/p.$injector<@file:///z:/angulartut/angular.js:36:266 c@file:///z:/angulartut/angular.js:34:300 d@file:///z:/angulartut/angular.js:35:1 f/<.instantiate@file:///z:/angulartut/angular.js:35:163 pd/this.$get</<@file:///z:/angulartut/angular.js:67:415 n/<@file:///z:/angulartut/angular.js:54:23 r@file:///z:/angulartut/angular.js:7:369 n@file:///z:/angulartut/angular.js:53:393 g@file:///z:/angulartut/angular.js:47:256 g@file:///z:/angulartut/angular.js:47:256 z/<@file:///z:/angulartut/angular.js:46:374 fc/c/</<@file:///z:/angulartut/angular.js:18:310 zd/this.$get</k.prototype.$eval@file:///z:/angulartut/angular.js:112:57 zd/this.$get</k.prototype.$apply@file:///z:/angulartut/angular.js:112:341 fc/c/<@file:///z:/angulartut/angular.js:18:268 d@file:///z:/angulartut/angular.js:35:27 fc/c@file:///z:/angulartut/angular.js:18:248 fc@file:///z:/angulartut/angular.js:18:380 xc@file:///z:/angulartut/angular.js:17:422 @file:///z:/angulartut/angular.js:215:30 a@file:///z:/angulartut/angular.js:145:67 oe/c/<@file:///z:/angulartut/angular.js:31:223 r@file:///z:/angulartut/angular.js:7:288 oe /c@file:///z:/angulartut/angular.js:31:207 "
if delete "viewthis" params, build page. "viewthis" in it, not.
and if easy solve, sorry. newbie in javascript...
javascript angularjs service
No comments:
Post a Comment