Home Angular 1.6.9 @uiRouter: Error: [ng:cpws] Can't copy! Making copies of Window or Scope instances is not supported
Reply: 0

Angular 1.6.9 @uiRouter: Error: [ng:cpws] Can't copy! Making copies of Window or Scope instances is not supported

Alexandra
1#
Alexandra Published in 2018-02-13 16:46:05Z

I am trying to use gulp-browsify to load all the dependencies in one app-release.js file.

The file builds fine but when I try to inject @uiRouter dependency I get the following error in the browser

Where as if I inject angular-route it works fine.

Here is the code

gulpfile.js

var gulp = require('gulp');
var rename = require('gulp-rename');
var browserify = require('gulp-browserify');
var buffer = require('gulp-buffer');

gulp.task('default', function() {
    gulp.src('app.js')
        .pipe(browserify({
            insertGlobals: false,
            debug: true
        }))
        .pipe(buffer())
        .pipe(rename('app-release.js'))
        .pipe(gulp.dest('app/'));
});

app.js

var angular = require('angular');
var uiRouter = require('@uirouter/angularjs');
var ngRoute = require('angular-route');

var app = angular.module("app",[uiRouter]);

app.config(function($stateProvider) {
    var helloState = {
        name: 'hello',
        url: '/',
        template: '<h3>hello world!</h3>'
    }

    var aboutState = {
        name: 'about',
        url: '/about',
        template: '<h3>Its the UI-Router hello world app!</h3>'
    }

    $stateProvider.state(helloState);
    $stateProvider.state(aboutState);
});

index.html

<!DOCTYPE html>
<html lang="en" ng-app="app">
<head>
    <meta charset="UTF-8">
    <title>Ui Router Test</title>
    <!--<script type="text/javascript" src="/node_modules/angular/angular.js"></script>-->
    <script src="app/app-release.js" type="application/javascript"></script>
</head>
<body>
<a ui-sref="hello">Hello</a>
<a ui-sref="about">About</a>
<p></p>
<!--<a href="#!red">Red</a>-->
<!--<a href="#!green">Green</a>-->
<!--<a href="#!blue">Blue</a>-->
<!--<div ng-view></div>-->
<ui-view></ui-view>

</body>
</html>

Thank you for providing help :)

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 4.671461 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO