小编Saj*_*kar的帖子

在Angular ui-router嵌套状态url更改,但模板未加载

我正在使用ui-router来嵌套状态和视图.当我单击链接时,URL将更改为子状态的URL,但模板不会加载.

例如,当URL更改为子状态时project/settings,project.settings.html不会加载相应的模板.

这是一个礼貌SSCCE Plunkr

以下是我的代码:

app.js

myApp.config(function ($stateProvider, $urlRouterProvider){
             $stateProvider
                  .state('project', {
                         url: "/project",
                         views:{
                         "content":{templateUrl: "partials/project.html"},
                         "header":{templateUrl: "partials/header"}
                         }
                       })

                  .state('project.settings', {
                          url: "/settings",
                          views:{
                           "content":{templateUrl: "partials/project.settings.html"},
                           "header":{templateUrl: "partials/header"}
                          }
                         }) 
            $urlRouterProvider.otherwise("/")                   
   }); 

    /* cheching whether the user is authentic or not*/


 myApp.run(function($rootScope,$location,$cookieStore,validateCookie,$state) {
      $rootScope.$on('$stateChangeStart',function(event,toState,toParams,fromState){
         if($cookieStore.get('user')){
            validateCookie.authService(function(result,error){
              if(!result){
                 $location.path("/");
              }else{
                $state.go('project.settings');
              }
            });   
         }
         else{
            $location.path("/"); 
         }
        });
    });
Run Code Online (Sandbox Code Playgroud)

的index.html

                <div ng-controller="userController">
                    <div ui-view="header"></div>
                    <div class="container" ui-view="content"></div>
                </div>
Run Code Online (Sandbox Code Playgroud)

project.html

            <div ng-controller="userController">
                <div class="details">
                    <a ui-sref=".settings" …
Run Code Online (Sandbox Code Playgroud)

javascript angularjs angular-ui-router

46
推荐指数
2
解决办法
3万
查看次数

输入Reactjs的预期相应JSX结束标记

在Reactjs中创建具有输入字段的组件时会发生错误 Error: Parse Error: Line 47: Expected corresponding JSX closing tag for input at http://localhost/chat-react/src/script.js:47:20 </div>

var Main = React.createClass({
    render: function() {
        return (
            <div className="card-action">
                <i class="mdi-action-account-circle prefix"></i>
                <input id="icon_prefix" type="text" class="validate">
            </div>
        );
    }
});
Run Code Online (Sandbox Code Playgroud)

javascript reactjs react-jsx reactjs-flux

45
推荐指数
3
解决办法
6万
查看次数