0


I'm trying to make a sample app using AngularJS ui-routing. I'm using a tutorial from here: https://angular-ui.github.io/ui-router/#resources I'm getting errors in the console when I run the site locally in Chrome.
Here are the errors:

  • Error: Failed to execute 'replaceState' on 'History': A history state object with URL 'file:///Users/******/Desktop/ui-routes-site/index.html#/index.html' cannot be created in a document with origin 'null'
  • Error: Circular dependency: uiViewDirective
  • Error: Circular dependency: uiSrefDirective

I'm not too sure what to do because I just copied the files from the tutorial. If anyone has seen something like this before or knows about circular errors with Angular, please help!

What my code looks like:

//index.html

<!doctype html>
<html ng-app="myApp">
<head>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.1.5/angular.min.js"></script>
    <script src="js/angular-ui-router.min.js"></script>
    <script>
        var myApp = angular.module('myApp', ['ui.router']);
        // For Component users, it should look like this:
        // var myApp = angular.module('myApp', [require('angular-ui-router')]);
    </script>
</head>
<body>
  <div ui-view></div>
  <a ui-sref="state1">State 1</a>
  <a ui-sref="state2">State 2</a>
</body>
</html>

// js/app.js
var routerApp = angular.module('routerApp', ['ui.router']);

routerApp.config(function($stateProvider, $urlRouterProvider) {

    $urlRouterProvider.otherwise('/home');

    $stateProvider

        // HOME STATES AND NESTED VIEWS ========================================
        .state('home', {
            url: '/home',
            templateUrl: 'partial-home.html'
        })

        // ABOUT PAGE AND MULTIPLE NAMED VIEWS =================================
        .state('about', {
            // we'll get to this in a bit       
        });

});

//partials/state1.html
<h1>State 1</h1>
</hr>
<a ui-sref="state1.list">Show List</a>
<div ui-view></div>

//partials/state1.list.html
<h3>List of State 1 Items</h3>
<ul>
  <li ng-repeat="item in items">{{ item }}</li>
</ul>

//js/angular-ui-router.min.js
 /**
 * State-based routing for AngularJS
 * @version v0.2.18
 * @link http://angular-ui.github.com/
 * @license MIT License, http://www.opensource.org/licenses/MIT
 */

/* commonjs package manager support (eg componentjs) */
if (typeof module !== "undefined" && typeof exports !== "undefined" && module.exports === exports){
  module.exports = 'ui.router';
}

(function (window, angular, undefined) {
/*jshint globalstrict:true*/
/*global angular:false*/
'use strict';

var isDefined = angular.isDefined,
    isFunction = angular.isFunction,
    isString = angular.isString,
    isObject = angular.isObject,
    isArray = angular.isArray,
    forEach = angular.forEach,
    extend = angular.extend,
    copy = angular.copy,
    toJson = angular.toJson;

function inherit(parent, extra) {
  return extend(new (extend(function() {}, { prototype: parent }))(), extra);
}

function merge(dst) {
  forEach(arguments, function(obj) {
    if (obj !== dst) {
      forEach(obj, function(value, key) {
        if (!dst.hasOwnProperty(key)) dst[key] = value;
      });
    }
  });
  return dst;
}

/**
 * Finds the common ancestor path between two states.
 *
 * @param {Object} first The first state.
 etc...
0

1 Answer 1

0

In you app.js, change

var routerApp = angular.module('myApp');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.