angularjs - My controller.js file breaks when I try to add another controller in it -
i trying work on project , build angular controllers hold data 2 different pages.
the code on first page is...
<div ng-app="app"> <div ng-controller="shopitemcontroller"> <div class="itm" ng-repeat="shopitem in shopitems"> <div class="imag"></div> <h2>{{ shopitems.name }}</h2> <div class="hf">buy it: {{ shopitems.price }}</div> <div class="hff">earn it: {{ shopitems.altprice }}</div> <div class="desc"><div>{{ shopitems.desc }}</div></div> <div class="prog"><div>{{ shopitems.progress }}</div></div> </div> </div> </div>
...and second page here.
<div ng-app="app"> <div ng-controller="trophyearnscontroller"> <div class="itm" ng-repeat="trophyearn in trophyearns"> <div class="imag"></div> <h2> {{ trophyearns.name }} </h2> <!--<div class="hf">buy it: {{ trophyearns.price }}</div> <div class="hff">earn it: {{ trophyearns.altprice }}</div>--> <div class="desc"><div> {{ trophyearns.desc }} </div></div> <div class="prog"><div> {{ trophyearns.progress }} </div></div> </div> </div> </div>
this controller
var shopitems = angular.module('shopitems', []); var trophyearns = angular.module('trophyearns', []); var app = angular.module('app', ['shopitems', 'trophyearns']); shopitems.controller('shopitemcontroller', function ($scope) { $scope.shopitems = [{ //id: 01, name: 'one', //img: '', price: '$3.99', altprice: '1 mile', desc: 'this fake description.', prog: '50%' },{ //id: 02, name: 'two', //img: '', price: '$3.99', altprice: '1 mile', desc: 'this fake description.', prog: '50%' }]; }); trophyearns.controller('trophyearnscontroller', function ($scope) { $scope.trophyearns = [{ //id: 01, name: 'one', //img: '', price: '$3.99', altprice: '1 mile', desc: 'this fake description.', prog: '50%' },{ //id: 02, name: 'two', //img: '', price: '$3.99', altprice: '1 mile', desc: 'this fake description.', prog: '50%' }]; });
this first time writing on own. works in fiddle one.
http://jsfiddle.net/galnova/rfg80gye/28/
but when changed around , tried add controller controller.js, broke.
any welcome. take me @ least week fix on own.
Comments
Post a Comment