无法通过$ routeParams获取页面,我做错了什么?

时间:2015-09-26 13:43:57

标签: angularjs

我的问题是这样的:在主页面中我将项目作为链接重复,但它们没有正确重定向。请保持温和,我正在学习AngularJS,而我在官方文档中找到的并没有帮助我,我希望你能。

page.html中

.schema

page.js

<div class="container">
  <div class="row">
    <div class="col-xs-12" ng-controller="PageCtrl as ctrl">
      <div ng-repeat="featured in ctrl.featured" class="text-centered">
        <h1>{{featured.titolo}}
          <small>{{featured.sottotitolo}}</small>
        </h1>
        <a ng-href="{{featured.id}}" class="thumbnail">
          <img class="img-responsive" alt="{{featured.etichetta}}" src="http://placehold.it/1518x1000" />
        </a>
      </div>
    </div>
  </div>
  <br>
  <br>
</div>

app.js

angular.module('myApp')
  .controller('PageCtrl', function () {
    this.featured = [
      {
        id: '#/products/item',
        titolo: 'some text',
        sottotitolo: 'some text',
        etichetta: "some text"
      },
      {
        id: '#/products/item',
        titolo: 'some text',
        sottotitolo: 'some text',
        etichetta: "some text"
      },
      {
        id: '#/products/item',
        titolo: 'some text',
        sottotitolo: 'some text',
        etichetta: "some text"
      }
    ];
  });

/controllers/item.js

app.config(function ($routeProvider) {
  $routeProvider
    .when(':productId', {
      templateUrl: 'views/products/:productId.html',
      controller: 'ItemCtrl',
      controllerAs: 'productId'
    })
});

0 个答案:

没有答案