0

問題は、.com/#/login などの URL にアクセスしてもエラーは表示されず、login.html ファイルも表示されないことです。

これは私が持っているものです:

<div id="content" ng-show></div>

staffApp.config(function($routeProvider, $locationProvider){
    $routeProvider
        .when('/admin',
            {
                templateUrl: '/partials/admin_panel.html',
                controller: 'AdminController',
                access: access.admin
            }
        )

        .when('/',
            {
                templateUrl: '/partials/login.html',
                controller:  'LoginController',
                access: access.anon
            }
        );

    // use the HTML5 History API
    $locationProvider.html5Mode(true);

});

アクセス コード、templateUrls、およびコントローラが適切に作成されていること。

4

2 に答える 2

1

ng-show には、変数をバインドする必要があります (例: ng-show="showContent" であり、それが真実である限り (showContent = true;)、表示されます)。

http://docs.angularjs.org/api/ng/directive/ngShow

ng-show が未定義にバインドされているため、現在は表示されていません。これは false の値です。

于 2014-03-19T18:57:08.810 に答える
0

最初にこれを試して、思うように表示されることを確認してください。

<div id="content" ng-show="true"></div>

ハードコーディングされた ngShow="true" を表示できないものをデバッグしたら、変数をいじることができます。

今これを...

<div id="content" ng-show="showMe">

In your controller || directive (that has access to the ng-show scope) initialize the variable.

$scope.showMe = false; (this is if you do not want it shown during initial DOM load, true otherwise)

Now in your controller || directive

function iShowThings(param){
  if( conditionIsTrue ){
    $scope.showMe = true; (when you wish to show it)
  }else{
    $scope.showMe = false; (hide it again)
  }
}

or perhaps a click event?
<button ng-click="toggleHiddenThing(showMe)">Toggle Div</button>

Then, in your controller || directive

$scope.toggleHiddenThing = function(showMe){ $scope.showMe = !showMe; }
In this case you would still initialize the showMe variable, then it's current
state would be passed into the function and then flipped with each click event.
于 2015-01-14T20:40:32.093 に答える