Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/409.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
Javascript Can';t负载组件';角UI路由器中的s模板_Javascript_Angularjs_Angular Ui Router_Angularjs Components - Fatal编程技术网

Javascript Can';t负载组件';角UI路由器中的s模板

Javascript Can';t负载组件';角UI路由器中的s模板,javascript,angularjs,angular-ui-router,angularjs-components,Javascript,Angularjs,Angular Ui Router,Angularjs Components,我正在开发一个Angular应用程序,并尝试将UI路由器与组件路由一起使用 这是我的app.js 'use strict'; // Declare app level module which depends on views, and components angular.module('myApp', [ 'ui.router', ]).config(['$stateProvider', '$urlRouterProvider', '$locationProvider', func

我正在开发一个Angular应用程序,并尝试将UI路由器与组件路由一起使用

这是我的app.js

'use strict';

// Declare app level module which depends on views, and components
angular.module('myApp', [
    'ui.router',
]).config(['$stateProvider', '$urlRouterProvider', '$locationProvider', function ($stateProvider, $urlRouterProvider, $locationProvider) {
    $locationProvider.hashPrefix('!');

    $urlRouterProvider.otherwise('/home');

    $stateProvider

        .state('cahome', {
            url: '/home',
            templateUrl: 'views/home.html'
        })
        .state('catest', {
            url: '/test',
            templateUrl: 'views/test.html'
        })
        .state('caprototype', {
            url: 'prototype',
            component: 'caPrototype', // The component's name
            resolve: {
              users: function() {
                return 'utenti';
              }
            }
        });

}]);

angular.module('myApp').run(function ($rootScope) {
    $rootScope.$on("$stateChangeError", console.log.bind(console));
});
这是我的组件文件:

/**
 * Created by firegloves on 05/06/17.
 */

angular.module('myApp')

    .component('caPrototype', {

        // bindings
        bindings: {
            users: '='
        },

        // controller
        controller: ['$scope', function ($scope) {

            console.log('*** prototype');
        }],

        // controller as
        controllerAs: 'prototypeCtrl',

        // templateUrl: 'views/ca-prototype.html',
        template: '<h3>PROTOTYPE TEMPLATE IN LINE</h3>'
    });
/**
*由Fire手套于2017年6月5日创建。
*/
angular.module('myApp')
.component('caPrototype'{
//绑定
绑定:{
用户:'='
},
//控制器
控制器:['$scope',函数($scope){
log(“***原型”);
}],
//控制器组件
controllerAs:'prototypeCtrl',
//templateUrl:'views/ca prototype.html',
模板:“行中的原型模板”
});
这是我的index.html

<!DOCTYPE html>
<!--[if lt IE 7]>      <html lang="en" ng-app="myApp" class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>         <html lang="en" ng-app="myApp" class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>         <html lang="en" ng-app="myApp" class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html lang="en" ng-app="myApp" class="no-js"> <!--<![endif]-->
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>My AngularJS App</title>
  <meta name="description" content="">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="bower_components/html5-boilerplate/dist/css/normalize.css">
  <link rel="stylesheet" href="bower_components/html5-boilerplate/dist/css/main.css">
  <link rel="stylesheet" href="app.css">
  <script src="bower_components/html5-boilerplate/dist/js/vendor/modernizr-2.8.3.min.js"></script>
</head>
<body>

    <a ui-sref="cahome">Home</a>
    <a ui-sref="catest">Test</a>
    <a ui-sref="caprototype">Prototype</a>


  <!--[if lt IE 7]>
      <p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
  <![endif]-->

  <div ui-view></div>

  <script src="bower_components/angular/angular.js"></script>
  <script src="bower_components/angular-ui-router/release/angular-ui-router.min.js"></script>
  <script src="app.js"></script>
  <script src="components/ca-prototype/ca-prototype.js"></script>
  <script src="components/version/version.js"></script>
  <script src="components/version/version-directive.js"></script>
  <script src="components/version/interpolate-filter.js"></script>
</body>
</html>

我的AngularJS应用程序
以改善您的体验

如果导航到状态cahome或catest,一切正常,但如果导航到caPrototype状态,我可以在控制台日志中读取控制器输出,但状态保持不变(或返回) 返回到主默认状态


有人能帮上忙吗?

好像在为我工作,检查一下你使用的是什么版本的ui路由器
$stateChange
事件已被弃用,组件中应避免双向
=
绑定。@PankajParkar谢谢,我将尝试从这一点开始example@georgeawg应该是1.0.2,谢谢你的建议