SORU
20 NİSAN 2013, CUMARTESİ


Kullanarak Açısal Şablonları İçi

Bir satır içi görünüm şablonu yüklemek istedim.

Tür bir komut dosyası etiketi text/ng-template şablon erdi ve temp1.html kimliği ayarlayın. ve burada, benim yapılandırma modülü gibi görünüyor

learningApp.config(function ($routeProvider) {
    $routeProvider.
        when("/first",{ controller: "SimpleController", templateUrl: "temp1.html"}).
        when("/second", {controller: "SimpleController", templateUrl: "temp2.html"}).
        otherwise({redirectTo : "/first"});
});

Bu isimde bir dosya arıyor beni teselli penceresi ne demek istediğimi GET http://localhost:41685/temp1.html 404 (Not Found) söyler.

Benim Soru: Nasıl içi şablonları kullanma yolları yapılandırabilirim?

Güncelleme: Burada server işlenmiş benim DOM gibi görünüyor

<!DOCTYPE html>
<html>
<head>
    <script src="/Scripts/angular.js"></script>
    <link href="/Content/bootstrap.css" rel="stylesheet"/>
</head>
<body>
    <div class="container">       
    <h2>Getting Started with Angular</h2>
    <div class="row">
        <div class="panel" ng-app="LearningApp">
            <div ng-view></div>
        </div>
    </div>

<script type="text/ng-template" id="temp1.html">
    <div class="view">
        <h2>First View</h2>
        <p>
            Search:<input type="text" ng-model="filterText" />
        </p>
        <ul class="nav nav-pills">
            <li ng-repeat="cust in customers | orderBy:'name' | filter: filterText "><a href="#">{{cust.name}} - {{cust.school}}</a></li>
        </ul>
    </div>
</script>

<script type="text/ng-template" id="temp2.html">
    <div class="view">
        <h2>Second View</h2>
        <p>
           Search:<input type="text" ng-model="filterText" />
        </p>
        <ul class="nav nav-pills">
            <li ng-repeat="cust in customers | orderBy:'name' | filter: filterText "><a href= "#">{{cust.name}} - {{cust.school}}</a></li>
        </ul>
    </div>
</script>
    </div>
    <script src="/Scripts/jquery-1.9.1.js"></script>
    <script src="/Scripts/bootstrap.js"></script>
    <script src="/Scripts/app/LearningApp.js"></script>
 </body>
</html>

CEVAP
20 NİSAN 2013, CUMARTESİ


Öyle, doğru yolda olduğunu, tek sorun etiketleri vardırdışarıdaDOM öğe ng-app Yönerge kullanılır. Eğer taşırsanız-line şablonları <body ng-app="LearningApp"> Bu eleman çalışmalıdır.

Ayrıca bu soru bulabilirsiniz: Is there a way to make AngularJS load partials in the beginning and not at when needed?

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • HTC Tutorials

    HTC Tutorial

    21 EYLÜL 2010
  • Caramella Girls

    Caramella Gi

    19 Mayıs 2008
  • williamfitzsimmons

    williamfitzs

    14 Mart 2008