question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

angular.js:13424 TypeError: d.scope.init is not a function

See original GitHub issue

Angular 1.5.3

Getting this error when the first toast is called, after we have to click the toast to disable it, the it works fine.

angular.js:13424 TypeError: d.scope.init is not a function
    at angular-toastr.min.js:1
    at angular.js:15757
    at m.$eval (angular.js:17025)
    at m.$digest (angular.js:16841)
    at angular.js:17064
    at e (angular.js:5824)
    at angular.js:6100

var CMWebApp = angular.module('CMWebApp', ['ngRoute', 'ngAnimate', 'ngCookies', 'toastr','ngMaterial']);

CMWebApp.config(function(toastrConfig) {
  angular.extend(toastrConfig, {
    autoDismiss: true,
    maxOpened: 0,
    newestOnTop: true,
    positionClass: 'toast-bottom-right',
    preventDuplicates: false,
    preventOpenDuplicates: true,
    allowHtml: true,
    closeButton: false,
    closeHtml: '<button>&times;</button>',
    extendedTimeOut: 1000,
    iconClasses: {
      error: 'toast-error',
      info: 'toast-info',
      success: 'toast-success',
      warning: 'toast-warning'
    },
    messageClass: 'toast-message',
    onHidden: null,
    onShown: null,
    onTap: null,
    progressBar: true,
    tapToDismiss: true,
    templates: {
      toast: appUrl + '/views/directives/toast/toast.html',
      progressbar: appUrl + '/views/directives/progressbar/progressbar.html'
    },
    timeOut: 3000,
    titleClass: 'toast-title',
    toastClass: 'toast'
  });
});


CMWebApp.config(function($routeProvider, $sceDelegateProvider, $locationProvider) {
  $sceDelegateProvider.resourceUrlWhitelist([
    'self',
    appUrl + '/**'
  ]);

  $routeProvider

    .when('/', {
    title: 'Homepage',
    templateUrl: appUrl + '/views/home.html',
    controller: 'mainCtrl'
  })

  $locationProvider.html5Mode({
    enabled: true,
  });

});

CMWebApp.controller('mainCtrl', function($scope, $rootScope, $sce, $route, $routeParams, $location, $http, $window, toastr) {

  $scope.$route = $route;
  $scope.$location = $location;
  $scope.$routeParams = $routeParams;
  $scope.domain = domain;
  $scope.home = webUrl;
  $scope.assets = appUrl;
  $scope.trustAsHtml = $sce.trustAsHtml;

  $scope.goTo = function(url) {
    $window.open(url, '_blank');
   toastr("Button clicked");
  }

  console.log("Page is loaded");

});

Please help!

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
Foxandxsscommented, Jun 14, 2016

For now then, delete that config and where you import toastr.js import toastr.tpl.js

0reactions
sagargulaticommented, Jun 14, 2016

Ok thanks 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular dataService.init is not a function when trying to call ...
I believe the problem is that the function init is not defined in the angular factory . The DataFactory function is returning an...
Read more >
ngInit - AngularJS: API
The ngInit directive allows you to evaluate an expression in the current scope. This directive can be abused to add unnecessary amounts of...
Read more >
undefined is not a function on init function in Angular factory
TypeError : undefined is not a function on init function in Angular ... I have simple factory in AngularJS: ... $rootScope = _$rootScope_;...
Read more >
Top 18 Most Common AngularJS Developer Mistakes - Toptal
angular.element(document.body).scope(). It can be useful even when not using jQuery with its CSS, but should not be used outside of the console.
Read more >
Angular ng-init Directive - W3Schools
Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, Python, PHP,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found