Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I was finally able to solve this. It is pretty easy after your read the documentation and play around</p> <p>Here is the directive:</p> <pre class="lang-js prettyprint-override"><code>angular.module('components', []).directive('category', function () { return { restrict: 'E', scope: {}, templateUrl: '/Scripts/app/partials/CategoryComponent.html', controller: function ($scope, $http, $attrs) { $http({ url: "api/FeaturedProducts/" + $attrs.catName, method: "get" }).success(function (data, status, headers, config) { $scope.Cat = data; }).error(function (data, status, headers, config) { $scope.data = data; $scope.status = status; }); } } }); </code></pre> <p>This this the main page with the same component called multiple times but with different parameter</p> <pre class="lang-html prettyprint-override"><code> &lt;ul class="unstyled"&gt; &lt;li&gt; &lt;category cat-name="Ultrabooks"&gt;&lt;/category&gt; &lt;/li&gt; &lt;li&gt; &lt;category cat-name="Tablets"&gt;&lt;/category&gt; &lt;/li&gt; &lt;li&gt; &lt;category cat-name="Laptops"&gt;&lt;/category&gt; &lt;/li&gt; &lt;li&gt; &lt;category cat-name="Digital SLR Cameras"&gt;&lt;/category&gt; &lt;/li&gt; </code></pre> <p>CategoryComponent.html</p> <pre class="lang-html prettyprint-override"><code>&lt;a href="#/Categories/{{Cat.CategoryName}}"&gt; &lt;h4&gt;{{Cat.CategoryName}}&lt;/h4&gt; &lt;/a&gt; &lt;div ng-switch on="status"&gt; &lt;div ng-switch-when="500" class="alert alert-error"&gt; {{status}} {{data}} &lt;/div&gt; &lt;div ng-switch-default&gt; &lt;ul class="unstyled columns"&gt; &lt;li class="pin" ng-repeat="p in Cat.Products"&gt; &lt;a href="#/reviews/{{p.UPC}}"&gt; &lt;h5&gt;{{p.ProductName}}&lt;/h5&gt; &lt;img src="{{p.ImageUrl}}"&gt; &lt;/a&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/div&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload