javascript - ZeroClipboard and RequireJS - ZeroClipboard is not defined -
i'm attempting use zeroclipboard inside angularjs/requirejs application.
i have put zeroclipboard.js location /assets/js/vendors/zeroclipboard.js
i have set main.js
of requirejs application
main.js
requirejs.config({ paths: { jquery: 'vendors/jquery.min', 'clipboard': 'vendors/zeroclipboard', underscore: 'vendors/underscore-min', angular: 'vendors/angular.min', 'angular-route': 'vendors/angular-route.min', 'controllers': 'controllers', 'services': 'services', 'filters': 'filters', 'directives': 'directives', 'app': 'app' }, shim: { underscore: { exports: '_' }, 'jquery': { 'exports': 'jquery' }, 'angular': { exports: 'angular' }, 'states': { deps: ['angular'], exports: 'states' }, 'angular-route': { deps: ['angular'] } }, priority: [ 'angular' ] }); requirejs(['angular', 'app', 'underscore', 'routes', 'vendors/jquery.min', 'services/services', 'directives/directives', 'filters/filters', 'controllers/controllers' ], function (angular, app, _) { angular.element(document).ready(function () { angular.bootstrap(document, ['app']); document.getelementsbytagname('html')[0].dataset.ngapp = 'app'; }); });
and inside controller calling zeroclipboard
controller.js
define(['clipboard'], function() { var appctrl = function($scope, $modal, $timeout, $log, $http, $routeparams, $rootscope) { var client = new zeroclipboard( $("li#copy-buildr") ); }; return appctrl; });
all seem referenceerror: zeroclipboard not defined
try changing controller.js
define(['clipboard'], function(zeroclipboard) {
note zeroclipboard in function arguments.
Comments
Post a Comment