2015-01-08 4 views
1

나는 angularjs에 익숙하지 않고 codeigniter에서 부분을로드하는 데 문제가 있습니다.angularjs 부분 코드와 함께

컨트롤러 :

function angular(){ 
$this->load->view('admin/header'); 
$this->load->view('admin/angulardata'); 
$this->load->view('admin/footer'); 
} 

angulardata.php

<div class="right"> 

    <div ng-view> 
    </div> 

</div> 

angular.js

var artistControllers=angular.module('artistControllers',[]); 
artistControllers.controller('ListController',function($scope){ 
$scope.artists=[ 
    { 
    "name":"Barot Bellingham", 
    "shortname":"Barot_Bellingham", 
    "reknown":"Royal Academy of Painting and Sculpture", 
    "bio":"Barot has just finished his final year at The Royal Academy of Painting and Sculpture, where he excelled in glass etching paintings and portraiture. Hailed as one of the most diverse artists of his generation, Barot is equally as skilled with watercolors as he is with oils, and is just as well-balanced in different subject areas. Barot's collection entitled \"The Un-Collection\" will adorn the walls of Gilbert Hall, depicting his range of skills and sensibilities - all of them, uniquely Barot, yet undeniably different" 
    }, 
    { 
    "name":"Jonathan G. Ferrar II", 
    "shortname":"Jonathan_Ferrar", 
    "reknown":"Artist to Watch in 2012", 
    "bio":"The Artist to Watch in 2012 by the London Review, Johnathan has already sold one of the highest priced-commissions paid to an art student, ever on record. The piece, entitled Gratitude Resort, a work in oil and mixed media, was sold for $750,000 and Jonathan donated all the proceeds to Art for Peace, an organization that provides college art scholarships for creative children in developing nations" 
    }, 
    { 
    "name":"Hillary Hewitt Goldwynn-Post", 
    "shortname":"Hillary_Goldwynn", 
    "reknown":"New York University", 
    "bio":"Hillary is a sophomore art sculpture student at New York University, and has already won all the major international prizes for new sculptors, including the Divinity Circle, the International Sculptor's Medal, and the Academy of Paris Award. Hillary's CAC exhibit features 25 abstract watercolor paintings that contain only water images including waves, deep sea, and river." 
    }, 
    { 
    "name":"Hassum Harrod", 
    "shortname":"Hassum_Harrod", 
    "reknown":"Art College in New Dehli", 
    "bio":"The Art College in New Dehli has sponsored Hassum on scholarship for his entire undergraduate career at the university, seeing great promise in his contemporary paintings of landscapes - that use equal parts muted and vibrant tones, and are almost a contradiction in art. Hassum will be speaking on \"The use and absence of color in modern art\" during Thursday's agenda." 
    }, 
    { 
    "name":"Jennifer Jerome", 
    "shortname":"Jennifer_Jerome", 
    "reknown":"New Orleans, LA", 
    "bio":"A native of New Orleans, much of Jennifer's work has centered around abstract images that depict flooding and rebuilding, having grown up as a teenager in the post-flood years. Despite the sadness of devastation and lives lost, Jennifer's work also depicts the hope and togetherness of a community that has persevered. Jennifer's exhibit will be discussed during Tuesday's Water in Art theme." 
    } 


] 

}); 

var myApp=angular.module('myApp',[ 
'ngRoute', 
'artistControllers' 

]); 
myApp.config(['$routeProvider',function($routeProvider){ 
$routeProvider. 
when('/list',{ 
templateUrl:'partials/list.php', 
controller:'ListController' 
}).otherwise({ 
redirectTo:'/list' 
}); 



}]); 
,691을 app.js 조회/관리/파셜에 위치하고

및 list.php는

<div> 
<input ng-model="query" placeholder="Search for Artists"> 
</div> 
    <ul> 
     <li ng-repeat="item in artists | filter: query"> 
     <div> 
     <h2>{{item.name}}</h2> 
     <h3>{{item.reknown}}</h3> 
     </div> 
     </li> 
    </ul> 

어떻게이 일을 할 수 list.php /?

+0

나는 그것이 멍청한 질문이라는 것을 알고있다. 그러나 ... 당신은 당신의'templateUrl'을 위해 다른 URL을 사용하려 했습니까? 'application/views/partials/list.php' 또는'views /'부분 만 있으면됩니다. – klauskpm

+0

@klauskpm 그렇습니다. 아무 것도 시도하지 않았습니다. – admir

+0

'.html' 파일 대신'list.php'를 사용하면 작동합니까? 몇 가지 구성이 될 수 있습니다. 또는 심지어 파일 사용 권한 문제. 왜냐하면, 당신이 말한대로, 그것은 괜찮습니다. 음 ... 내 루트 폴더는 ** game-on **이고, ** app.routes.js **는'game-on/app'에 있지만, 내 경로는'app/components/home/homeView.html'. – klauskpm

답변

2

해결책 : 한 줄만 변경하십시오.

첫 번째 방법 : -

여기에 전체 경로 보내기

templateUrl:'partials/list.php', 

변경 그것에 :

templateUrl:'[full-path]/partials/list.php', 

예를.[full-path] = http://localhost/mysystem/

두 번째 방법 : -

templateUrl:base_url+'partials/list.php', 

: 코드 라인은 다음과 같이된다

var base_url="http://localhost/mysstem/"; 

당신은 같은 자바 스크립트 변수로 기본 경로를 저장할 수 있습니다 희망이 도움이됩니다.

관련 문제