{"action":"created","issue":{"url":"https://api.github.com/repos/sagiegurari/angular-web-notification/issues/18","repository_url":"https://api.github.com/repos/sagiegurari/angular-web-notification","labels_url":"https://api.github.com/repos/sagiegurari/angular-web-notification/issues/18/labels{/name}","comments_url":"https://api.github.com/repos/sagiegurari/angular-web-notification/issues/18/comments","events_url":"https://api.github.com/repos/sagiegurari/angular-web-notification/issues/18/events","html_url":"https://github.com/sagiegurari/angular-web-notification/issues/18","id":178152291,"number":18,"title":"Cannot read property 'showNotification' of undefined","user":{"login":"surfjedi","id":536809,"avatar_url":"https://avatars.githubusercontent.com/u/536809?v=3","gravatar_id":"","url":"https://api.github.com/users/surfjedi","html_url":"https://github.com/surfjedi","followers_url":"https://api.github.com/users/surfjedi/followers","following_url":"https://api.github.com/users/surfjedi/following{/other_user}","gists_url":"https://api.github.com/users/surfjedi/gists{/gist_id}","starred_url":"https://api.github.com/users/surfjedi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/surfjedi/subscriptions","organizations_url":"https://api.github.com/users/surfjedi/orgs","repos_url":"https://api.github.com/users/surfjedi/repos","events_url":"https://api.github.com/users/surfjedi/events{/privacy}","received_events_url":"https://api.github.com/users/surfjedi/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-09-20T19:19:31Z","updated_at":"2016-09-20T19:25:18Z","closed_at":null,"body":"<!-- markdownlint-disable first-header-h1 no-multiple-blanks first-line-h1 required-headers -->\r\n#### Problem Description\r\n\r\nCool module! thanks! \r\n\r\nI am trying to use this in my project but it appears that this moduleis not getting injected properly?\r\n\r\nits built with webpack, ES6 and angular 1.5.8.\r\n\r\nIs the angular-web-notification.js file set  up to be exported and used as a module?\r\n\r\n\r\n\r\n\r\n#### Code Example\r\n\r\n````js\r\n\r\n  function vmListCtrl($location, $q, $rootScope, config, dataservice, logger, vmCache, webNotification) {\r\n\r\n    /*jshint validthis: true */\r\n    var ctrl = this;\r\n\r\n    ctrl.vms = [];\r\n\r\n    ctrl.searchFlag = false;\r\n    ctrl.search = {\r\n      status: '!DELETED'\r\n    };\r\n\r\n    ctrl.$onInit = function () {\r\n      var promises = [getVMs()];\r\n      return $q.all(promises).then(function () {\r\n        logger.info('Activated vm-list View', config.uiMsgTitle);\r\n\r\n        $rootScope.$on('VMsChanged', function () {\r\n          resetAll();\r\n          getVMs();\r\n        });\r\n      });\r\n    };\r\n\r\n    function resetAll() {\r\n      ctrl.vms = [];\r\n    }\r\n\r\n    function getVMs() {\r\n      return dataservice.getVMs()\r\n        .then(function (data) {\r\n          ctrl.vms = vmCache.get('vms');\r\n          if (ctrl.vms && ctrl.vms.length > 0) {\r\n            ctrl.vms.sort(function (a, b) {\r\n              return a.vm_name > b.vm_name;\r\n            });\r\n          }\r\n        });\r\n    }\r\n\r\n    ctrl.searchChanged = function () {\r\n      if (ctrl.searchFlag) {\r\n        ctrl.search.status = '';\r\n      } else {\r\n        ctrl.search.status = '!DELETED';\r\n      }\r\n    };\r\n\r\n    ctrl.loadDetails = function (vmName) {\r\n      $location.path('/vm-detail/' + vmName);\r\n    };\r\n\r\n    ctrl.vmCreate = function () {\r\n      $location.path('/vm-create');\r\n    };\r\n\r\n    ctrl.showAlert = function () {\r\n      webNotification.showNotification(scope.notificationTitle, {\r\n        body: 'scope.notificationText',\r\n        onClick: function onNotificationClicked() {\r\n          console.log('Notification clicked.');\r\n        },\r\n        autoClose: 4000 //auto close the notification after 4 seconds (you can manually close it via hide function)\r\n      }, function onShow(error, hide) {\r\n        if (error) {\r\n          window.alert('Unable to show notification: ' + error.message);\r\n        } else {\r\n          console.log('Notification Shown.');\r\n\r\n          setTimeout(function hideNotification() {\r\n            console.log('Hiding notification....');\r\n            hide(); //manually close the notification (you can skip this if you use the autoClose option)\r\n          }, 5000);\r\n        }\r\n      });\r\n    }\r\n\r\n\r\n  }\r\nexport default vmListCtrl;\r\n\r\n````\r\n\r\n#### Error Stack/Info (if any)\r\n\r\nangular.js?7f65:13920 TypeError: [NG-Modular Error] Cannot read property 'showNotification' of undefined\r\n    at vmListCtrl.ctrl.showAlert (eval at 144 (http://localhost:8080/bundle.js:4:17283), <anonymous>:63:20)\r\n    at fn (eval at compile (eval at <anonymous> (http://localhost:8080/vendor.bundle.js:32:27247)), <anonymous>:4:265)\r\n    at expensiveCheckFn (eval at <anonymous> (http://localhost:8080/vendor.bundle.js:32:27247), <anonymous>:15906:18)\r\n    at callback (eval at <anonymous> (http://localhost:8080/vendor.bundle.js:32:27247), <anonymous>:25885:17)\r\n    at Scope.$eval (eval at <anonymous> (http://localhost:8080/vendor.bundle.js:32:27247), <anonymous>:17682:28)\r\n    at Scope.$apply (eval at <anonymous> (http://localhost:8080/vendor.bundle.js:32:27247), <anonymous>:17782:25)\r\n    at HTMLButtonElement.eval (eval at <anonymous> (http://localhost:8080/vendor.bundle.js:32:27247), <anonymous>:25890:23)\r\n    at defaultHandlerWrapper (eval at <anonymous> (http://localhost:8080/vendor.bundle.js:32:27247), <anonymous>:3497:11)\r\n    at HTMLButtonElement.eventHandler (eval at <anonymous> (http://localhost:8080/vendor.bundle.js:32:27247), \r\n"},"comment":{"url":"https://api.github.com/repos/sagiegurari/angular-web-notification/issues/comments/248406293","html_url":"https://github.com/sagiegurari/angular-web-notification/issues/18#issuecomment-248406293","issue_url":"https://api.github.com/repos/sagiegurari/angular-web-notification/issues/18","id":248406293,"user":{"login":"surfjedi","id":536809,"avatar_url":"https://avatars.githubusercontent.com/u/536809?v=3","gravatar_id":"","url":"https://api.github.com/users/surfjedi","html_url":"https://github.com/surfjedi","followers_url":"https://api.github.com/users/surfjedi/followers","following_url":"https://api.github.com/users/surfjedi/following{/other_user}","gists_url":"https://api.github.com/users/surfjedi/gists{/gist_id}","starred_url":"https://api.github.com/users/surfjedi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/surfjedi/subscriptions","organizations_url":"https://api.github.com/users/surfjedi/orgs","repos_url":"https://api.github.com/users/surfjedi/repos","events_url":"https://api.github.com/users/surfjedi/events{/privacy}","received_events_url":"https://api.github.com/users/surfjedi/received_events","type":"User","site_admin":false},"created_at":"2016-09-20T19:25:18Z","updated_at":"2016-09-20T19:25:18Z","body":"Here is webpack config (where it gets bundled)\r\n\r\n\r\n````js\r\n\r\nvar path = require('path'),\r\n    webpack = require('webpack'),\r\n    libPath = path.join(__dirname, 'src/client'),\r\n    wwwPath = path.join(__dirname, 'www'),\r\n\r\n// pkg = require('./package.json'),\r\n    CopyWebpackPlugin = require('copy-webpack-plugin'),\r\n    HtmlWebpackPlugin = require('html-webpack-plugin');\r\n\r\n/**\r\n * Env\r\n * Get npm lifecycle event to identify the environment\r\n */\r\nvar ENV = process.env.npm_lifecycle_event;\r\nvar isTest = ENV === 'test' || ENV === 'test-watch';\r\nvar isProd = ENV === 'build';\r\n\r\n\r\n\r\nmodule.exports = function makeWebpackConfig () {\r\n    /**\r\n     * Config\r\n     * Reference: http://webpack.github.io/docs/configuration.html\r\n     * This is the object where all configuration gets set\r\n     */\r\n    var config = {};\r\n    config.context = path.join(__dirname, 'src/client'),\r\n\r\n        /**\r\n     * Entry\r\n     * Reference: http://webpack.github.io/docs/configuration.html#entry\r\n     * Should be an empty object if it's generating a test build\r\n     * Karma will set this when it's a test build\r\n     */\r\n    config.entry = isTest ? {} : {\r\n        app: path.join(libPath, 'app/app.module.js'),\r\n        vendor: [\r\n            'jquery',\r\n            'angular',\r\n            'angular-animate',\r\n            'angular-resource',\r\n            'angular-route',\r\n            'angular-sanitize',\r\n            'angular-socket-io',\r\n            'angular-ui-bootstrap',\r\n            'c3',\r\n            'd3',\r\n            'toastr',\r\n            'moment',\r\n            './vendor/ngplus-overlay.js',\r\n            'angular-web-notification'\r\n        ]\r\n    };\r\n\r\n    /**\r\n     * Output\r\n     * Reference: http://webpack.github.io/docs/configuration.html#output\r\n     * Should be an empty object if it's generating a test build\r\n     * Karma will handle setting it up for you when it's a test build\r\n     */\r\n    config.output = isTest ? {} : {\r\n        // Absolute output directory\r\n        path: path.join(wwwPath),\r\n        filename: 'bundle.js'\r\n        // filename: 'bundle-[hash:6].js'\r\n    };\r\n\r\n    /**\r\n     * Devtool\r\n     * Reference: http://webpack.github.io/docs/configuration.html#devtool\r\n     * Type of sourcemap to use per build type\r\n     */\r\n    if (isTest) {\r\n        config.devtool = 'inline-source-map';\r\n    } else if (isProd) {\r\n        config.devtool = 'source-map';\r\n    } else {\r\n        config.devtool = 'eval-source-map';\r\n    }\r\n\r\n    /**\r\n     * Loaders\r\n     * Reference: http://webpack.github.io/docs/configuration.html#module-loaders\r\n     * List: http://webpack.github.io/docs/list-of-loaders.html\r\n     * This handles most of the magic responsible for converting modules\r\n     */\r\n\r\n    // Initialize module\r\n    config.module = {\r\n        preLoaders: [],\r\n        loaders: [\r\n            //run all js thru babel\r\n            {\r\n                test: /\\.js$/,\r\n                loader: 'babel',\r\n                exclude: /node_modules/,\r\n                query: {\r\n                    presets: ['es2015']\r\n                }\r\n            },\r\n            //load all css into a js bundle which you can require\r\n            {\r\n                test: /\\.css$/,\r\n                loader: 'style!css',\r\n                exclude: /node_modules/\r\n            },\r\n            //run all sass thru loader, then css loader, then into js bundle\r\n            {\r\n                test: /\\.scss$/,\r\n                loader: 'style!css!sass',\r\n                exclude: /node_modules/\r\n            },\r\n            //load images thru loader and either produce data url or url https://github.com/webpack/url-loader\r\n            {\r\n                test: /\\.(eot|woff|woff2|ttf|svg|png|jpg)$/,\r\n                loader: 'url-loader?limit=25000&name=[name].[ext]',\r\n                exclude: /node_modules/\r\n            },\r\n            // https://github.com/webpack/raw-loader\r\n            {\r\n                test: /\\.html$/,\r\n                loader: 'raw',\r\n                exclude: /node_modules/\r\n            }\r\n        ]\r\n    };\r\n\r\n    // ISPARTA LOADER\r\n    // Reference: https://github.com/ColCh/isparta-instrumenter-loader\r\n    // Instrument JS files with Isparta for subsequent code coverage reporting\r\n    // Skips node_modules and files that end with .test.js\r\n    // if (isTest) {\r\n    //     config.module.preLoaders.push({\r\n    //         test: /\\.js$/,\r\n    //         exclude: [\r\n    //             /node_modules/,\r\n    //             /\\.spec\\.js$/\r\n    //         ],\r\n    //         loader: 'isparta-loader'\r\n    //     })\r\n    // }\r\n\r\n\r\n    /**\r\n     * Plugins\r\n     * Reference: http://webpack.github.io/docs/configuration.html#plugins\r\n     * List: http://webpack.github.io/docs/list-of-plugins.html\r\n     */\r\n    config.plugins = [\r\n\r\n        //try to cut down loading all locale from moment\r\n        new webpack.IgnorePlugin(/^\\.\\/locale$/, /moment$/),\r\n        //custom plugin to build module or not\r\n        new webpack.DefinePlugin({\r\n            ON_DEV: process.env.NODE_ENV === 'dev'\r\n        }),\r\n        // OccurenceOrderPlugin: Assign the module and chunk ids by occurrence count. : https://webpack.github.io/docs/list-of-plugins.html#occurenceorderplugin\r\n        new webpack.optimize.OccurenceOrderPlugin(),\r\n\r\n        new webpack.optimize.UglifyJsPlugin({\r\n            mangle: false\r\n        }),\r\n        new CopyWebpackPlugin([\r\n            { from: './content', to: './content' },\r\n            { from: 'app/**/*.html' },\r\n            {from: '../../node_modules/bootstrap/dist/css/bootstrap.min.css', to: './vendor/css/bootstrap.min.css'},\r\n            {from: '../../node_modules/angular-ui-bootstrap/dist/ui-bootstrap-csp.css', to: './vendor/css/ui-bootstrap-csp.css'},\r\n            {from: '../../node_modules/font-awesome/fonts', to: './vendor/fonts'},\r\n            {from: '../../node_modules/font-awesome/css/font-awesome.min.css', to: './vendor/css/font-awesome.min.css'},\r\n            {from: '../../node_modules/socket.io-client/socket.io.js', to: './vendor/socket.io.js'}\r\n        ])\r\n    ];\r\n\r\n    // Skip rendering index.html in test mode\r\n    if (!isTest) {\r\n        // Reference: https://github.com/ampedandwired/html-webpack-plugin\r\n        // Render index.html\r\n        config.plugins.push(\r\n\r\n            //just copied for now since we don't need hasing or anything for now\r\n            // HtmlWebpackPlugin: Simplifies creation of HTML files to serve your webpack bundles : https://www.npmjs.com/package/html-webpack-plugin\r\n            new HtmlWebpackPlugin({\r\n                // filename: 'index.html',\r\n                // template: './app/index.html',\r\n                // pkg: pkg,\r\n                template: path.join(libPath, 'index.html'),\r\n                hash: false,\r\n                title: 'title'\r\n\r\n            }),\r\n            new webpack.optimize.CommonsChunkPlugin({\r\n                name: 'vendor',\r\n                filename: 'vendor.bundle.js'\r\n            })\r\n        )\r\n    }\r\n\r\n    // Add build specific plugins\r\n    if (isProd) {\r\n        config.plugins.push(\r\n            // Reference: http://webpack.github.io/docs/list-of-plugins.html#noerrorsplugin\r\n            // Only emit files when there are no errors\r\n            new webpack.NoErrorsPlugin(),\r\n\r\n            // Reference: http://webpack.github.io/docs/list-of-plugins.html#dedupeplugin\r\n            // Dedupe modules in the output\r\n            new webpack.optimize.DedupePlugin(),\r\n\r\n            // Reference: http://webpack.github.io/docs/list-of-plugins.html#uglifyjsplugin\r\n            // Minify all javascript, switch loaders to minimizing mode\r\n            new webpack.optimize.UglifyJsPlugin(),\r\n\r\n            // Copy assets from the public folder\r\n            // Reference: https://github.com/kevlened/copy-webpack-plugin\r\n            new CopyWebpackPlugin([{\r\n                from: __dirname + '/src/public'\r\n            }])\r\n        )\r\n    }\r\n\r\n    /**\r\n     * Dev server configuration\r\n     * Reference: http://webpack.github.io/docs/configuration.html#devserver\r\n     * Reference: http://webpack.github.io/docs/webpack-dev-server.html\r\n     */\r\n    config.devServer = {\r\n        stats: 'minimal',\r\n        historyApiFallback: true,\r\n        inline: true,\r\n        proxy: {\r\n            '/api': {\r\n                target: 'http://localhost:3000',\r\n                secure: false\r\n            }\r\n        }\r\n    };\r\n\r\n    return config;\r\n}();\r\n\r\n````"}}
{"actor":{"display_login":"surfjedi"}}