2017-03-21 15 views
1

示すNGリピートを使って自分のページに配列からオブジェクトを表示するいくつかの問題を持っていません。AngularJS - ngのリピートは

私は、同様のタスクの前に、角使ってきたと私はコントローラとHTMLでのNGリピート要素をロードした構造の同じ種類を使用していたが、仕事に以下の例を得ることができません。

誰が示すのコンテンツを停止するかもしれないものを見ることができますか?

Codepen:http://codepen.io/anon/pen/BWYXMx

HTML:

<body ng-app="portfolioApp" data-spy="scroll" data-target="#navbar"> 

    <div id="logo"> 

     <a href="index2.html"></a> 

     <img src="img/logo-basic-dark.png" alt="Logo"> 

    </div> 

    <div class="container-fluid"> 

     <nav class="navbar navbar-default navbar-fixed-top"> 

      <div class="navbar-header"> 

       <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar"> 

        <span class="icon-bar"></span> 

        <span class="icon-bar"></span> 

        <span class="icon-bar"></span>       

       </button> 

      </div> 

      <div class="collapse navbar-collapse" id="navbar"> 

       <ul class="pull-right nav navbar-nav" id="socialNav"> 

        <li class="socialIcon"><a href="#" target="_blank"><span class="fa fa-github fa-lg"></span></a></li> 

        <li class="socialIcon"><a href="#" target="_blank"><span class="fa fa-linkedin fa-lg"></span></a></li> 

        <li class="socialIcon"><a href="#" target="_blank"><span class="fa fa-file-pdf-o fa-lg"></span></a></li> 

       </ul> 

       <ul class="pull-right nav navbar-nav"> 

        <li class="navLink"><a href="#home" alt="Home Button">Home</a></li> 

        <li class="navLink"><a href="#about" alt="About Button">About Me</a></li> 

        <li class="navLink"><a href="#skills" alt="Skills Button">My Skills</a></li> 

        <li class="navLink"><a href="#work" alt="Work Button">My Work</a></li> 

        <li class="navLink"><a href="#contact" alt="Contact Button">Contact Me</a></li> 

       </ul> 

      </div> 

     </nav> 

    </div> 

    <main data-simplebar> 

     <section id="home"> 

      <div class="sectionContent"> 

       <h1 id="intro">Home Intro</h1> 

      </div> 

     </section> 

     <section id="about"> 

      <div class="sectionContent"> 

       <div class="row"> 

        <div class="col-sm-12 col-md-10"> 

         <h1>About Me</h1> 

         <p>About Description</p> 

        </div> 

        <div class="col-sm-12 col-md-2"> 



        </div> 

       </div> 

      </div> 

     </section> 

     <section id="skills"> 



     </section> 

     <section id="work" ng-controller="projectsController"> 

      <div class="sectionContent"> 

       <div class="project col-sm-12 col-md-6 col-lg-3" ng-repeat="project in projects"> 

        <div> 

         <h2>{{project.name}}</h2> 

         <h4>{{project.description}}</h4> 

         <a ng-href="#">View Project</a> 

        </div> 

       </div> 

      </div> 

     </section> 

     <section id="contact"> 

      <div class="sectionContent"> 



      </div> 

     </section> 

    </main> 

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script> 

    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> 

    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.min.js"></script> 

    <script src="https://use.fontawesome.com/7758cac280.js"></script> 

    <script src="https://unpkg.com/[email protected]/dist/simplebar.js"></script> 

    <script src="js/app.js"></script> 

    <script src="js/navScroll.js"></script> 

</body> 

JS:

(function() { 

var app = angular.module('portfolioApp', []); 

app.controller('projectsController', ['$scope', function($scope) { 

    $scope.title = 'Projects'; 
    $scope.projects = [ 

     { 
      name: 'Name1', 
      description: 'Description1', 
      link: '#' 
     }, 

     { 
      name: 'Name2', 
      description: 'Description2', 
      link: '#' 
     }, 

     { 
      name: 'Name3', 
      description: 'Description3', 
      link: '#' 
     }, 

     { 
      name: 'Name4', 
      description: 'Description4', 
      link: '#' 
     } 

    ]; 

}]); 

}); 
+4

以下の作業コードを確認してください...置換する '(function(){...}); 'with '(function(){...})(); ' – Gianpolo

+0

はまた、あなたのスクリプトで複数回(角度、jqueryの、ブートストラップ)をロードしている – devqon

+0

devqon - のみCodepen自体から直接ロードした後、HTMLコードからそれらを削除するのを忘れて、どんな効果 –

答えて

0

あなたはIFEE機能を実行していない

var app = angular.module('portfolioApp', []); 
 

 
app.controller('projectsController', ['$scope', function($scope) { 
 
    $scope.title = 'Projects'; 
 
    $scope.projects = [ 
 
     
 
     { 
 
      name: 'Name1', 
 
      description: 'Description1', 
 
      link: '#' 
 
     }, 
 
     
 
     { 
 
      name: 'Name2', 
 
      description: 'Description2', 
 
      link: '#' 
 
     }, 
 
     
 
     { 
 
      name: 'Name3', 
 
      description: 'Description3', 
 
      link: '#' 
 
     }, 
 
     
 
     { 
 
      name: 'Name4', 
 
      description: 'Description4', 
 
      link: '#' 
 
     } 
 
     
 
    ]; 
 
    
 
}]); 
 
          
\t /* GENERAL TEXT STYLING */ 
 

 
\t ::selection 
 
\t { 
 
\t \t background:#1C16F6; 
 
\t \t color:#fff; 
 
\t } 
 

 
\t ::-moz-selection 
 
\t { 
 
\t \t background:#1C16F6; 
 
\t \t color:#fff; 
 
\t } 
 

 
\t ::-webkit-selection 
 
\t { 
 
\t \t background:#1C16F6; 
 
\t \t color:#fff; 
 
\t } 
 

 
\t a, p, input, textarea, h1, h2, h3, h4 
 
\t { 
 
\t \t color: #272930; 
 
\t } 
 

 
\t a, p, input, textarea 
 
\t { 
 
\t \t font-weight: 400; 
 
\t \t font-family: 'Heebo', 'Open Sans', sans-serif; 
 
\t } 
 

 
\t h1, h2, h3, h4 
 
\t { 
 
\t \t font-family: 'Poppins', 'Montserrat', sans-serif; 
 
\t } 
 

 
\t a 
 
\t { 
 
\t \t transition: 0.2s ease; 
 
\t \t -moz-transition: 0.2s ease; 
 
\t \t -webkit-transition: 0.2s ease; 
 
\t } 
 

 

 
\t /* GENERAL LAYOUT */ 
 

 
\t html, body 
 
\t { 
 
\t \t padding: 0; 
 
\t \t margin: 0; 
 
\t \t background-color: #f3f3f3; 
 
\t \t overflow-x: hidden; 
 
\t } 
 

 
\t main 
 
\t { 
 
\t \t position: relative; 
 
\t \t overflow-y: auto; 
 
\t \t min-height: 100vh; 
 
\t } 
 

 
\t #logo 
 
\t { 
 
\t \t position: fixed; 
 
\t \t top: 30px; 
 
\t \t left: 30px; 
 
\t \t display: flex; 
 
\t \t align-items: center; 
 
\t \t z-index: 99; 
 
\t } 
 

 
\t #logo > img 
 
\t { 
 
\t \t height: 25px; 
 
\t } 
 

 
\t #logo > a 
 
\t { 
 
\t \t position: absolute; 
 
\t \t top: 0; 
 
\t \t left: 0; 
 
\t \t display: block; 
 
\t \t height: 100%; 
 
\t \t width: 100%; 
 
\t \t cursor: pointer; 
 
\t } 
 

 
\t /* NAV */ 
 

 
\t nav, 
 
\t .navbar-default 
 
\t { 
 
\t \t width: 100%; 
 
\t \t z-index: 90; 
 
\t \t border: none; 
 
\t \t background: transparent; 
 
\t \t padding: 30px 30px 0 30px; 
 
\t } 
 

 
\t .nav > li > a, 
 
\t .nav > li > a:focus 
 
\t { 
 
\t \t background: transparent; 
 
\t \t color: #272930; 
 
\t \t font-size: 13px; 
 
\t } 
 

 
\t #navbar .navbar-nav li > a 
 
\t { 
 
\t \t padding: 5px 10px; 
 
\t \t margin: 0 10px; 
 
\t } 
 

 
\t #navbar .navbar-nav li > a:focus 
 
\t { 
 
\t \t color: #777; 
 
\t } 
 

 
\t #navbar .navbar-nav .active > a, 
 
\t #navbar .navbar-nav .active > a:focus 
 
\t { 
 
\t \t color: #272930; 
 
\t \t background: transparent; 
 
\t } 
 

 
\t #navbar .navbar-nav#socialNav li > a 
 
\t { 
 
\t \t margin: 0 10px; 
 
\t } 
 

 
\t #navbar .navbar-nav#socialNav li > a:first-of-type 
 
\t { 
 
\t \t padding-left: 0; 
 
\t } 
 

 
\t #navbar .navbar-nav#socialNav li > a:last-of-type 
 
\t { 
 
\t \t padding-right: 0; 
 
\t } 
 

 

 
\t /* SECTIONS */ 
 

 
\t section 
 
\t { 
 
\t \t min-height: 100vh; 
 
\t \t width: 100%; 
 
\t \t background: transparent; 
 
\t \t z-index: 99; 
 
\t } 
 

 
\t section:nth-of-type(even) 
 
\t { 
 
\t \t background: #fdfdfd; 
 
\t } 
 

 
\t .sectionContent 
 
\t { 
 
\t \t height: 100%; 
 
\t \t width: 100%; 
 
\t \t padding: 100px 30px; 
 
\t \t box-sizing: border-box; 
 
\t \t -webkit-box-sizing: border-box; 
 
\t \t -moz-box-sizing: border-box; 
 
\t } 
 

 

 
\t /* HOME SECTION */ 
 

 
\t #home h1#intro 
 
\t { 
 
\t \t font-size: 35px; 
 
\t \t color: #272930; 
 
\t \t width: 80%; 
 
\t } 
 

 

 
\t /* ABOUT SECTION */ 
 

 
\t #about 
 
\t { 
 
\t \t 
 
\t } 
 

 

 
\t /* WORK SECTION */ 
 

 
\t #work 
 
\t { 
 
\t \t height: auto; 
 
\t \t background-image: url('../img/work.png'); 
 
\t \t background-size: cover; 
 
\t \t background-position: center center; 
 
\t } 
 

 
\t #work .sectionContent 
 
\t { 
 
\t \t height: auto; 
 
\t \t padding: 0; 
 
\t } 
 

 
\t #work .project 
 
\t { 
 
\t \t height: 100vh; 
 
\t \t padding: 0 30px; 
 
\t \t background: #fff; 
 
\t \t display: flex; 
 
\t \t align-items: center; 
 
\t \t transition: all linear 0.1s; 
 
\t \t -webkit-transition: all linear 0.1s; 
 
\t \t -moz-transition: all linear 0.1s; 
 
\t } 
 

 
\t #work .project > div 
 
\t { 
 
\t \t display: flex; 
 
\t \t justify-content: center; 
 
\t \t flex-direction: column; 
 
\t \t text-align: left; 
 
\t } 
 

 
\t #work .project:first-of-type:hover 
 
\t { 
 
\t \t background: rgba(130, 160, 72, 0.9); 
 
\t } 
 

 
\t #work .project:nth-of-type(2):hover 
 
\t { 
 
\t \t background: rgba(193, 100, 144, 0.9); 
 
\t } 
 

 
\t #work .project:nth-of-type(3):hover 
 
\t { 
 
\t \t background: rgba(69, 156, 140, 0.9); 
 
\t } 
 

 
\t #work .project:nth-of-type(4):hover 
 
\t { 
 
\t \t background: rgba(241, 137, 76, 0.9); 
 
\t } 
 

 
\t #work .project h2 
 
\t { 
 
\t \t font-weight: 700; 
 
\t \t margin: 0; 
 
\t \t transition: all linear 0.1s; 
 
\t \t -webkit-transition: all linear 0.1s; 
 
\t \t -moz-transition: all linear 0.1s; 
 
\t } 
 

 
\t #work .project h4 
 
\t { 
 
\t \t margin-top: 20px; 
 
\t \t transition: all linear 0.1s; 
 
\t \t -webkit-transition: all linear 0.1s; 
 
\t \t -moz-transition: all linear 0.1s; 
 
\t } 
 

 
\t #work .project:hover h2, 
 
\t #work .project:hover h4 
 
\t { 
 
\t \t color: #fff; 
 
\t } 
 

 
\t #work .project a 
 
\t { 
 
\t \t margin-top: 30px; 
 
\t \t border: 1.5px solid #777; 
 
\t \t background: #fff; 
 
\t \t padding: 10px 15px; 
 
\t \t max-width: 150px; 
 
\t \t text-align: center; 
 
\t \t color: #777; 
 
\t } 
 

 
\t #work .project a:hover 
 
\t { 
 
\t \t text-decoration: none; 
 
\t \t border: 1.5px solid #272930; 
 
\t \t color: #272930; 
 
\t } 
 

 

 
\t /* CONTACT SECTION */ 
 

 
\t #contact 
 
\t { 
 
\t \t 
 
\t }
\t  <body ng-app="portfolioApp" data-spy="scroll" data-target="#navbar"> 
 
    
 
    <div id="logo"> 
 

 
     <a href="index2.html"></a> 
 

 
     <img src="img/logo-basic-dark.png" alt="Logo"> 
 

 
    </div> 
 
    
 
    <div class="container-fluid"> 
 
    
 
     <nav class="navbar navbar-default navbar-fixed-top"> 
 

 
      <div class="navbar-header"> 
 

 
       <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar"> 
 

 
        <span class="icon-bar"></span> 
 

 
        <span class="icon-bar"></span> 
 

 
        <span class="icon-bar"></span>       
 

 
       </button> 
 

 
      </div> 
 

 
      <div class="collapse navbar-collapse" id="navbar"> 
 

 
       <ul class="pull-right nav navbar-nav" id="socialNav"> 
 

 
        <li class="socialIcon"><a href="#" target="_blank"><span class="fa fa-github fa-lg"></span></a></li> 
 

 
        <li class="socialIcon"><a href="#" target="_blank"><span class="fa fa-linkedin fa-lg"></span></a></li> 
 

 
        <li class="socialIcon"><a href="#" target="_blank"><span class="fa fa-file-pdf-o fa-lg"></span></a></li> 
 

 
       </ul> 
 

 
       <ul class="pull-right nav navbar-nav"> 
 

 
        <li class="navLink"><a href="#home" alt="Home Button">Home</a></li> 
 

 
        <li class="navLink"><a href="#about" alt="About Button">About Me</a></li> 
 

 
        <li class="navLink"><a href="#skills" alt="Skills Button">My Skills</a></li> 
 

 
        <li class="navLink"><a href="#work" alt="Work Button">My Work</a></li> 
 

 
        <li class="navLink"><a href="#contact" alt="Contact Button">Contact Me</a></li> 
 

 
       </ul> 
 

 
      </div> 
 

 
     </nav> 
 
    
 
    </div> 
 
    
 
    <main data-simplebar> 
 
     
 
     <section id="home"> 
 
      
 
      <div class="sectionContent"> 
 
       
 
       <h1 id="intro">Home Intro</h1> 
 
       
 
      </div> 
 
      
 
     </section> 
 
     
 
     <section id="about"> 
 
      
 
      <div class="sectionContent"> 
 
       
 
       <div class="row"> 
 
       
 
        <div class="col-sm-12 col-md-10"> 
 
       
 
         <h1>About Me</h1> 
 

 
         <p>About Description</p> 
 
       
 
        </div> 
 
        
 
        <div class="col-sm-12 col-md-2"> 
 
         
 
         
 
         
 
        </div> 
 
       
 
       </div> 
 
       
 
      </div> 
 
      
 
     </section> 
 
     
 
     <section id="skills"> 
 
      
 
      
 
      
 
     </section> 
 
     
 
     <section id="work" ng-controller="projectsController"> 
 
      
 
      <div class="sectionContent"> 
 
       
 
       <div class="project col-sm-12 col-md-6 col-lg-3" ng-repeat="project in projects"> 
 
        
 
        <div> 
 
        
 
         <h2>{{project.name}}</h2> 
 

 
         <h4>{{project.description}}</h4> 
 

 
         <a ng-href="#">View Project</a> 
 
        
 
        </div> 
 
        
 
       </div> 
 
       
 
      </div> 
 
      
 
     </section> 
 
     
 
     <section id="contact"> 
 
      
 
      <div class="sectionContent"> 
 
       
 
       
 
       
 
      </div> 
 
      
 
     </section> 
 
     
 
    </main> 
 
    
 
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script> 
 
    
 
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> 
 
    
 
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.min.js"></script> 
 
    
 
    <script src="https://use.fontawesome.com/7758cac280.js"></script> 
 
    
 
    <script src="https://unpkg.com/[email protected]/dist/simplebar.js"></script> 
 
    
 
    <script src="js/app.js"></script> 
 
    
 
    <script src="js/navScroll.js"></script> 
 
    
 
</body>