Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/78.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 AngularJs.Config是如何工作的?_Javascript_Jquery_Angularjs_Html - Fatal编程技术网

Javascript AngularJs.Config是如何工作的?

Javascript AngularJs.Config是如何工作的?,javascript,jquery,angularjs,html,Javascript,Jquery,Angularjs,Html,我正在尝试创建一个导航栏,这就是我的html代码的样子 <div class="container"> <div class="row"> <div class="navbar navbar-default"> <div class="navbar-header"> <ul class="nav navbar-nav">

我正在尝试创建一个导航栏,这就是我的html代码的样子

<div class="container">
    <div class="row">
        <div class="navbar navbar-default">
            <div class="navbar-header">
                <ul class="nav navbar-nav">
                    <li><span class="navbar-brand">Registration</span></li>
                </ul>
            </div>
            <div class="navbar-collapse collapse">
                <ul class="nav navbar-nav">
                    <li><a href="/Courses">Courses</a></li>
                    <li><a href="/Instructors">Instructors</a></li>
                </ul>
            </div>

        </div>
        <div ng-view></div>
    </div>
</div>
这是我创建的两个模板。。。。。。。。。。 1.Course.cshtml:

<div class="row">
    <h2>Course</h2>
    <div class="span10">
        <table class="table table-condensed table-hover">
            <tr>
                <th>Course</th>
                <th>Course Name</th>
                <th>Instructor</th>
            </tr>
            <tr ng-repeat="course in courses">
                <td>{{course.number}}</td>
                <td>{{course.name}}</td>
                <td>{{course.instructor}}</td>
            </tr>
        </table>
    </div>
</div>

课程
课程
课程名称
教练
{{course.number}
{{course.name}
{{课程.讲师}
2.讲师.cshtml:

<div class="row">
    <h2>Instructor</h2>
    <div class="span10">
        <table class="table table-condensed table-hover">
            <tr>
                <th>Room Number</th>
                <th>Instructor's Name</th>
                <th>Email</th>
            </tr>
            <tr ng-repeat="instructor in instructors">
                <td>{{instructor.roomNumber}}</td>
                <td>{{instructor.name}}</td>
                <td>{{instructor.email}}</td>
            </tr>
        </table>
    </div>
</div>

教练
房间号
讲师姓名
电子邮件
{{讲师室号}
{{讲师.姓名}
{{讲师.电子邮件}

您无法通过url访问cshtml文件,因为它们只是经过分析的
C#
razor引擎,我希望您从控制器操作加载这些.cshtml文件。使用asp.net mvc控制器操作加载它,而不是
cshtml
的指令路径

代码

var registrationModule = angular.module("registrationModule", [])
.config(function($routeProvider, $locationProvider) {

  $routeProvider.when('/Courses', {
    //templates controller Course action will return Course.cshtml
    templateUrl: '/Templates/Course',
    controller: 'CoursesController'
  });

  $routeProvider.when('/Instructors', {
    //templates controller Instructor action will return Instructor.cshtml
    templateUrl: '/Templates/Instructor',
    controller: 'InstructorsController'
  });

  $locationProvider.html5Mode(true);

});

您的语法无效。为什么你的代码会做与操作代码不同的事情(假设语法是固定的)?@charlietfl是的,那是我的错,它与
C
side有关。你是否设置了服务器来识别html5模式的虚拟目录?
var registrationModule = angular.module("registrationModule", [])
.config(function($routeProvider, $locationProvider) {

  $routeProvider.when('/Courses', {
    //templates controller Course action will return Course.cshtml
    templateUrl: '/Templates/Course',
    controller: 'CoursesController'
  });

  $routeProvider.when('/Instructors', {
    //templates controller Instructor action will return Instructor.cshtml
    templateUrl: '/Templates/Instructor',
    controller: 'InstructorsController'
  });

  $locationProvider.html5Mode(true);

});