angular.js - AngularJs controls page output by defining anchor links
大家讲道理
大家讲道理 2017-05-15 16:53:14
0
1
685
<!DOCTYPE html>
<html ng-app="ngView">
<head>
    <title>分页显示</title>
    <meta charset="utf-8">
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script> 
    <script src="http://code.angularjs.org/angular-1.0.1.min.js"></script>
</head>
<body>


<p ng-view>
    <p  ng-controller="test">
        
    </p>
</p>





<script type="text/javascript">
 angular.module('ngView', [],
    function($routeProvider){
      $routeProvider.when('/test1',
        {
          templateUrl: 'demo.html',
          controller: 'test'
        }
      )
      .when('/test2',
      {
        templateUrl:'slinder.html',
        controller: 'test'
      }
      );
    }
  );
</script>


</body>
</html>

Demo.html is not displayed when outputting /#/test1 in the URL. What is the problem? ?

大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

reply all(1)
Peter_Zhu

Tell me a few questions
1: ng-app is generally written in the body
2: When defining routes, it is best to write them in a $routeProvider
3: Your routing definition is wrong. You only write the template without specifying the controller, which is also the reason why it does not work.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template