javascript - injecting $http into angular "usestrict" service -


i'm trying inject $http angular service, called controller populate data our api. continue hit error:

error: [$injector:strictdi] infoservice not using explicit annotation , cannot invoked in strict mode http://errors.angularjs.org/1.5.7/$injector/strictdi?p0=infoservice

below service defined strict. how can inject $http?

the service must remain strict.

'use strict';    angular.module('bitsgantt')      .service('infoservice', function infoservice($http) {          return {              getsampledata: function() {              	// $http({              	// 	method: 'get',              	// 	url:               	// })                  return [                          // order optional. if not specified assigned automatically                          {name: 'milestones', height: '3em', sortable: false, drawtask: false, classes: 'gantt-row-milestone', color: '#45607d', tasks: [                              // dates can specified string, timestamp or javascript date object. data attribute can used attach custom object                              {name: 'kickoff', color: '#93c47d', from: '2016-10-07t09:00:00', to: '2016-10-07t10:00:00', data: 'can contain custom data or object'},                              {name: 'concept approval', color: '#93c47d', from: new date(2016, 9, 18, 18, 0, 0), to: new date(2016, 9, 18, 18, 0, 0), est: new date(2016, 9, 16, 7, 0, 0), lct: new date(2016, 9, 19, 0, 0, 0)},                              {name: 'development finished', color: '#93c47d', from: new date(2016, 10, 15, 18, 0, 0), to: new date(2016, 10, 15, 18, 0, 0)},                              {name: 'shop running', color: '#93c47d', from: new date(2016, 10, 22, 12, 0, 0), to: new date(2016, 10, 22, 12, 0, 0)},                              {name: 'go-live', color: '#93c47d', from: new date(2016, 10, 29, 16, 0, 0), to: new date(2016, 10, 29, 16, 0, 0)}                          ], data: 'this here can contain custom data, or object!'},                          {name: 'status meetings', tasks: [                              {name: 'bits demo #1', color: '#9fc5f8', from: new date(2016, 9, 25, 15, 0, 0), to: new date(2016, 9, 25, 18, 30, 0)},                              {name: 'bits demo #2', color: '#9fc5f8', from: new date(2016, 10, 1, 15, 0, 0), to: new date(2016, 10, 1, 18, 0, 0)},                              {name: 'bits demo #3', color: '#9fc5f8', from: new date(2016, 10, 8, 15, 0, 0), to: new date(2016, 10, 8, 18, 0, 0)},                              {name: 'bits demo #4', color: '#9fc5f8', from: new date(2016, 10, 15, 15, 0, 0), to: new date(2016, 10, 15, 18, 0, 0)},                              {name: 'bits demo #5', color: '#9fc5f8', from: new date(2016, 10, 24, 9, 0, 0), to: new date(2016, 10, 24, 10, 0, 0)}                          ]},                          {name: 'kickoff', movable: {allowresizing: false}, tasks: [                              {name: 'day 1', color: '#9fc5f8', from: new date(2016, 9, 7, 9, 0, 0), to: new date(2016, 9, 7, 17, 0, 0),                                  progress: {percent: 100, color: '#3c8cf8'}, movable: false},                              {name: 'day 2', color: '#9fc5f8', from: new date(2016, 9, 8, 9, 0, 0), to: new date(2016, 9, 8, 17, 0, 0),                                  progress: {percent: 100, color: '#3c8cf8'}},                              {name: 'day 3', color: '#9fc5f8', from: new date(2016, 9, 9, 8, 30, 0), to: new date(2016, 9, 9, 12, 0, 0),                                  progress: {percent: 100, color: '#3c8cf8'}}                          ]},                          {name: 'create concept', tasks: [                              {name: 'create concept', priority: 20, content: '<i class="fa fa-cog" ng-click="scope.handletaskiconclick(task.model)"></i> {{task.model.name}}', color: '#f1c232', from: new date(2016, 9, 10, 8, 0, 0), to: new date(2016, 9, 16, 18, 0, 0), est: new date(2016, 9, 8, 8, 0, 0), lct: new date(2016, 9, 18, 20, 0, 0),                                  progress: 100}                          ]},                          {name: 'finalize concept', tasks: [                              {id: 'finalize concept', name: 'finalize concept', priority: 10, color: '#f1c232', from: new date(2016, 9, 17, 8, 0, 0), to: new date(2016, 9, 18, 18, 0, 0),                                  progress: 100}                          ]},                          {name: 'development', children: ['sprint 1', 'sprint 2', 'sprint 3', 'sprint 4'], content: '<i class="fa fa-file-code-o" ng-click="scope.handlerowiconclick(row.model)"></i> {{row.model.name}}'},                          {name: 'sprint 1', tooltips: false, tasks: [                              {id: 'product list view', name: 'product list view', color: '#f1c232', from: new date(2016, 9, 21, 8, 0, 0), to: new date(2016, 9, 25, 15, 0, 0),                                  progress: 25, dependencies: [{to: 'order basket'}, {from: 'finalize concept'}]}                          ]},                          {name: 'sprint 2', tasks: [                              {id: 'order basket', name: 'order basket', color: '#f1c232', from: new date(2016, 9, 28, 8, 0, 0), to: new date(2016, 10, 1, 15, 0, 0),                                  dependencies: {to: 'checkout'}}                          ]},                          {name: 'sprint 3', tasks: [                              {id: 'checkout', name: 'checkout', color: '#f1c232', from: new date(2016, 10, 4, 8, 0, 0), to: new date(2016, 10, 8, 15, 0, 0),                                  dependencies: {to: 'login & signup & admin views'}}                          ]},                          {name: 'sprint 4', tasks: [                              {id: 'login & signup & admin views', name: 'login & signup & admin views', color: '#f1c232', from: new date(2016, 10, 11, 8, 0, 0), to: new date(2016, 10, 15, 15, 0, 0),                                  dependencies: [{to: 'hw'}, {to: 'sw / dns/ backups'}]}                          ]},                          {name: 'hosting'},                          {name: 'setup', tasks: [                              {id: 'hw', name: 'hw', color: '#f1c232', from: new date(2016, 10, 18, 8, 0, 0), to: new date(2016, 10, 18, 12, 0, 0)}                          ]},                          {name: 'config', tasks: [                              {id: 'sw / dns/ backups', name: 'sw / dns/ backups', color: '#f1c232', from: new date(2016, 10, 18, 12, 0, 0), to: new date(2016, 10, 21, 18, 0, 0)}                          ]},                          {name: 'server', parent: 'hosting', children: ['setup', 'config']},                          {name: 'deployment', parent: 'hosting', tasks: [                              {name: 'depl. & final testing', color: '#f1c232', from: new date(2016, 10, 21, 8, 0, 0), to: new date(2016, 10, 22, 12, 0, 0), 'classes': 'gantt-task-deployment'}                          ]},                          {name: 'workshop', tasks: [                              {name: 'on-side education', color: '#f1c232', from: new date(2016, 10, 24, 9, 0, 0), to: new date(2016, 10, 25, 15, 0, 0)}                          ]},                          {name: 'content', tasks: [                              {name: 'supervise content creation', color: '#f1c232', from: new date(2016, 10, 26, 9, 0, 0), to: new date(2016, 10, 29, 16, 0, 0)}                          ]},                          {name: 'documentation', tasks: [                              {name: 'technical/user documentation', color: '#f1c232', from: new date(2016, 10, 26, 8, 0, 0), to: new date(2016, 10, 28, 18, 0, 0)}                          ]}                     //close of return                      ];             //close of function                       },              getsampletimespans: function() {                  return [                          {                              from: new date(2016, 9, 21, 8, 0, 0),                              to: new date(2016, 9, 25, 15, 0, 0),                              name: 'sprint 1 timespan'                              //priority: undefined,                              //classes: [],                              //data: undefined                          }                     //close of return                           ];            //close of function                        }        //close of main return                };    //close of info service            })  ;

try wrapping function inside array, , declare $http first element of array, looks this:

'use strict';  angular.module('bitsgantt')     .service('infoservice', ['$http', function infoservice($http) {         return {             getsampledata: function() {                 // $http({                 //  method: 'get',                 //  url:                  // })                 return [                         // order optional. if not specified assigned automatically                         {name: 'milestones', height: '3em', sortable: false, drawtask: false, classes: 'gantt-row-milestone', color: '#45607d', tasks: [                             // dates can specified string, timestamp or javascript date object. data attribute can used attach custom object                             {name: 'kickoff', color: '#93c47d', from: '2016-10-07t09:00:00', to: '2016-10-07t10:00:00', data: 'can contain custom data or object'},                             {name: 'concept approval', color: '#93c47d', from: new date(2016, 9, 18, 18, 0, 0), to: new date(2016, 9, 18, 18, 0, 0), est: new date(2016, 9, 16, 7, 0, 0), lct: new date(2016, 9, 19, 0, 0, 0)},                             {name: 'development finished', color: '#93c47d', from: new date(2016, 10, 15, 18, 0, 0), to: new date(2016, 10, 15, 18, 0, 0)},                             {name: 'shop running', color: '#93c47d', from: new date(2016, 10, 22, 12, 0, 0), to: new date(2016, 10, 22, 12, 0, 0)},                             {name: 'go-live', color: '#93c47d', from: new date(2016, 10, 29, 16, 0, 0), to: new date(2016, 10, 29, 16, 0, 0)}                         ], data: 'this here can contain custom data, or object!'},                         {name: 'status meetings', tasks: [                             {name: 'bits demo #1', color: '#9fc5f8', from: new date(2016, 9, 25, 15, 0, 0), to: new date(2016, 9, 25, 18, 30, 0)},                             {name: 'bits demo #2', color: '#9fc5f8', from: new date(2016, 10, 1, 15, 0, 0), to: new date(2016, 10, 1, 18, 0, 0)},                             {name: 'bits demo #3', color: '#9fc5f8', from: new date(2016, 10, 8, 15, 0, 0), to: new date(2016, 10, 8, 18, 0, 0)},                             {name: 'bits demo #4', color: '#9fc5f8', from: new date(2016, 10, 15, 15, 0, 0), to: new date(2016, 10, 15, 18, 0, 0)},                             {name: 'bits demo #5', color: '#9fc5f8', from: new date(2016, 10, 24, 9, 0, 0), to: new date(2016, 10, 24, 10, 0, 0)}                         ]},                         {name: 'kickoff', movable: {allowresizing: false}, tasks: [                             {name: 'day 1', color: '#9fc5f8', from: new date(2016, 9, 7, 9, 0, 0), to: new date(2016, 9, 7, 17, 0, 0),                                 progress: {percent: 100, color: '#3c8cf8'}, movable: false},                             {name: 'day 2', color: '#9fc5f8', from: new date(2016, 9, 8, 9, 0, 0), to: new date(2016, 9, 8, 17, 0, 0),                                 progress: {percent: 100, color: '#3c8cf8'}},                             {name: 'day 3', color: '#9fc5f8', from: new date(2016, 9, 9, 8, 30, 0), to: new date(2016, 9, 9, 12, 0, 0),                                 progress: {percent: 100, color: '#3c8cf8'}}                         ]},                         {name: 'create concept', tasks: [                             {name: 'create concept', priority: 20, content: '<i class="fa fa-cog" ng-click="scope.handletaskiconclick(task.model)"></i> {{task.model.name}}', color: '#f1c232', from: new date(2016, 9, 10, 8, 0, 0), to: new date(2016, 9, 16, 18, 0, 0), est: new date(2016, 9, 8, 8, 0, 0), lct: new date(2016, 9, 18, 20, 0, 0),                                 progress: 100}                         ]},                         {name: 'finalize concept', tasks: [                             {id: 'finalize concept', name: 'finalize concept', priority: 10, color: '#f1c232', from: new date(2016, 9, 17, 8, 0, 0), to: new date(2016, 9, 18, 18, 0, 0),                                 progress: 100}                         ]},                         {name: 'development', children: ['sprint 1', 'sprint 2', 'sprint 3', 'sprint 4'], content: '<i class="fa fa-file-code-o" ng-click="scope.handlerowiconclick(row.model)"></i> {{row.model.name}}'},                         {name: 'sprint 1', tooltips: false, tasks: [                             {id: 'product list view', name: 'product list view', color: '#f1c232', from: new date(2016, 9, 21, 8, 0, 0), to: new date(2016, 9, 25, 15, 0, 0),                                 progress: 25, dependencies: [{to: 'order basket'}, {from: 'finalize concept'}]}                         ]},                         {name: 'sprint 2', tasks: [                             {id: 'order basket', name: 'order basket', color: '#f1c232', from: new date(2016, 9, 28, 8, 0, 0), to: new date(2016, 10, 1, 15, 0, 0),                                 dependencies: {to: 'checkout'}}                         ]},                         {name: 'sprint 3', tasks: [                             {id: 'checkout', name: 'checkout', color: '#f1c232', from: new date(2016, 10, 4, 8, 0, 0), to: new date(2016, 10, 8, 15, 0, 0),                                 dependencies: {to: 'login & signup & admin views'}}                         ]},                         {name: 'sprint 4', tasks: [                             {id: 'login & signup & admin views', name: 'login & signup & admin views', color: '#f1c232', from: new date(2016, 10, 11, 8, 0, 0), to: new date(2016, 10, 15, 15, 0, 0),                                 dependencies: [{to: 'hw'}, {to: 'sw / dns/ backups'}]}                         ]},                         {name: 'hosting'},                         {name: 'setup', tasks: [                             {id: 'hw', name: 'hw', color: '#f1c232', from: new date(2016, 10, 18, 8, 0, 0), to: new date(2016, 10, 18, 12, 0, 0)}                         ]},                         {name: 'config', tasks: [                             {id: 'sw / dns/ backups', name: 'sw / dns/ backups', color: '#f1c232', from: new date(2016, 10, 18, 12, 0, 0), to: new date(2016, 10, 21, 18, 0, 0)}                         ]},                         {name: 'server', parent: 'hosting', children: ['setup', 'config']},                         {name: 'deployment', parent: 'hosting', tasks: [                             {name: 'depl. & final testing', color: '#f1c232', from: new date(2016, 10, 21, 8, 0, 0), to: new date(2016, 10, 22, 12, 0, 0), 'classes': 'gantt-task-deployment'}                         ]},                         {name: 'workshop', tasks: [                             {name: 'on-side education', color: '#f1c232', from: new date(2016, 10, 24, 9, 0, 0), to: new date(2016, 10, 25, 15, 0, 0)}                         ]},                         {name: 'content', tasks: [                             {name: 'supervise content creation', color: '#f1c232', from: new date(2016, 10, 26, 9, 0, 0), to: new date(2016, 10, 29, 16, 0, 0)}                         ]},                         {name: 'documentation', tasks: [                             {name: 'technical/user documentation', color: '#f1c232', from: new date(2016, 10, 26, 8, 0, 0), to: new date(2016, 10, 28, 18, 0, 0)}                         ]}                    //close of return                     ];            //close of function                      },             getsampletimespans: function() {                 return [                         {                             from: new date(2016, 9, 21, 8, 0, 0),                             to: new date(2016, 9, 25, 15, 0, 0),                             name: 'sprint 1 timespan'                             //priority: undefined,                             //classes: [],                             //data: undefined                         }                    //close of return                          ];           //close of function                       }]       //close of main return               };   //close of info service           }) ; 

Comments