I am currently working on creating a sample app using AngularJS ui-routing.
There is a tutorial that I am following which can be found here
When I try to run the site locally in Chrome, I am encountering some errors in the console.
Below are the errors that I am seeing:
- 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
Since I simply copied the files from the tutorial, I am not sure what steps to take. I would appreciate any help or guidance on how to address circular errors with Angular if anyone has encountered this issue before!
This is a snippet of 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...