0
제품 목록이 있다고 가정 해 보겠습니다. 우리는 그들을 통해 PHP를 가져옵니다. 예를 들어 :각도 항목 동기화 (제품)
우리의보기에 그런$products = Product::all();
:
<div class='product' ng-repeat="product in products">
<div class="name">{{ product.name }}</div>
<div class="short-info">{{ product.short }}</div>
<div class="quantity">
<button class="add-one" ng-click="removeOne(product)">-</button>
<input type="text" ng-model="{{ product.quantity }}">
<button class="remove-one" ng-click="addOne(product)">+</button>
</div>
</div>
하지만 어떻게 우리가 이러한 것들을 함께 작동 할 수있다 : 각도에서
<?php foreach ($products as $product): ?>
<div class='product'>
<div class="name"><?php echo $product->name ?></div>
<div class="short-info"><?php echo $product->short ?></div>
<div class="quantity">
<button class="add-one">-</button>
<input type="text" value="<?php echo $product->quantity ?>">
<button class="remove-one">+</button>
</div>
</div>
<?php endforeach ?>
우리는 일부는 다음과 같이 생각해야합니다? 을 php (seo puproses)로 즉시 채우고 각도가 제공하는 기능을 갖고 싶습니다.
**EXAMPLE:**
User navigate to http://.../catalog
User instantly see product list (because they were rendered with php)
User instantly can change product amount (here comes angular ng-model)
어떻게 수행하나요? 감사합니다
페이지 소스 (http://take.ms/626VU)를 볼 때 각도 템플릿 (렌더링되지 않은 제품) 만 표시됩니다 – user2573863
ng-app를 사용하여 각도 모듈을 설치하고 컨트롤러를 사용하는 경우 ng 지시문 -init는 컨트롤러에서 제품 목록을 선언하는 것과 같습니다. 그래서 페이지에는 올바른 바인딩이있는 제품 목록이 표시됩니다. – Mikalai
당신은 스스로 그것을 테스트 할 수 있고 그렇지 않은 것을 볼 수 있습니다. "Cmd + opt + u"에서는 렌더링 된 제품이 js – user2573863