Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/unity3d/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs ui路由器正在呈现周围的html内容_Angularjs - Fatal编程技术网

Angularjs ui路由器正在呈现周围的html内容

Angularjs ui路由器正在呈现周围的html内容,angularjs,Angularjs,我有一个非常简单的配置,不工作。ui视图未呈现模板 HTML: ConfigJS (function () { 'use strict'; var core = angular.module('barmehealth'); core.config(function($urlRouterProvider, $stateProvider) { $urlRouterProvider.otherwise('/'); $stateProvider .state('reg

我有一个非常简单的配置,不工作。ui视图未呈现模板

HTML:

ConfigJS

(function () {
  'use strict';

  var core = angular.module('barmehealth');

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

  $urlRouterProvider.otherwise('/');

  $stateProvider
    .state('register', {
    url: '/register',
    templateUrl: '/views/register.html',
     controller: 'RegisterCtrl'
    });
  });
}());
当我通过单击要注册的链接转到路由时,ui视图使用视图标记呈现整个html页面,而不是状态中给定的模板


我在templateUrl中的路径错误。应该是的

templateUrl:“/app/views/register.html”


有人知道视图标记加载周围html是否是默认行为吗?

有两件事:1。register.html的内容是什么?2.你能检查一下浏览器是否真的加载了它吗?它只是用register这个词div,根本没有加载它。所以问题可能是应用程序加载的是index.html而不是register.html,这就是为什么你会看到周围的html。尝试修复模板URL。我认为删除第一个斜杠就足够了,views/register.html。我刚刚发布了我在添加这个时发现的内容。非常感谢。
(function () {
  'use strict';

  angular.module('barmehealth', ['ui.router'])
  .controller('RegisterCtrl', function($scope) {

  });
}());
(function () {
  'use strict';

  var core = angular.module('barmehealth');

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

  $urlRouterProvider.otherwise('/');

  $stateProvider
    .state('register', {
    url: '/register',
    templateUrl: '/views/register.html',
     controller: 'RegisterCtrl'
    });
  });
}());