我在AngularJS中制作一个选择框,但在角度路由中使用它时遇到了一个错误

时间:2017-03-22 05:30:49

标签: html angularjs routing

我在AngularJS中制作了一个选择框,但遇到了问题 在角度路由中使用它。我不知道在哪里放这个脚本代码,因为如果我把脚本标签放在主html然后路由不工作,如果我把脚本标签放在相应的html文件中,那么下拉不工作。

这是我的代码:

来自index.html的

<
!DOCTYPE html >
<
html lang = "en-US" >
<
head >
<
script src = "https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js" > < /script> <
   script src = "https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-route.js" > < /script> <
link rel = "stylesheet"
 href = "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" >
<
script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js" > < /script> <
      script src = "    https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" > < /script> <
style >
h1, h2, h3, h4, h5, h6 {
    color: #585858; }
</style>
</head>
 <body ng-app= "myApp" >
        <
        h3 class = "text-center main-heading" > Calculator < /h3> <
        div class = "col-sm-12" >
        <
        div class = "row" >
        <
        div class = "col-sm-3" >
        <
        table class = "table table-bordered table-hover text-center" >
        <
        tbody >
        <
        tr > < td > < a href = "#/" > Home < /a></td > < /tr> <
        tr > < td > < a href = "#painting" > painting < /a></td > < /tr> <
        tr > < td > < a href = "#plastering" > plastering < /a></td > < /tr> <
        /tbody> <
        /table> <
        /div> <
        div class = "col-sm-9" >
        <
        div ng - view > < /div> <
        /div> <
        /div> <
        /div> <
        script src = "route.js" > < /script> <
        /body> <
        /html> 

    and
    for other file where i want to use select box code is

    <
    div class = "col-sm-12"
    ng - controller = "myCtrl" >
    <
    img src = "painting.png"
    class = "img-responsive"
    style = "width:100%;" >
    <
    div class = "clearfix" >
    <
    /div> <
    div class = "col-sm-12 text-center" >
    <
    h3 > Select Material Type < /h3> <
    /div> <
    div class = "row" >
    <
    div class = "col-sm-4" >
    <
    div class = "form-group" >
    <
    label
    for = "sel1" > Select Material Unit < /label> <
    select class = "form-control"
    id = "sel1" >
    <
    option value = "u1" > Meter < /option> <
    option value = "u2" > Feet < /option> <
    /select> <
    /div> <
    /div> <
    div class = "col-sm-4" >
    <
    div class = "form-group" >
    <
    label
    for = "sel1" > Select Category < /label> <
    select ng - model = "selectedName"
    class = "form-control"
    ng - options = "x for x in names" > < /select> <
    /div> <
    /div> <
    div class = "col-sm-4" >
    <
    div class = "form-group" >
    <
    label
    for = "sel1" > Select Type Of Work < /label> <
    select class = "form-control" > < /select> <
    /div> <
    /div> <
    /div> <
    /div> <
    script >
    var select = angular.module('myApp', []);
    select.controller('myCtrl', function($scope) {
        $scope.names = ["Emil", "Tobias", "Linus"];
    }); <
    /script>

0 个答案:

没有答案