Whenever I try to add it into the app.js file, it keeps coming up as undefined.
app.js
(function () {
var tkcApp = angular.module('TKC', []);
var shuffle = function (o) {
for (var j, x, i = o.length; i; j = parseInt(Math.random() * i),
x = o[--i], o[i] = o[j], o[j] = x);
};
tkcApp.controller('ShuffleCtrl', function ($scope) {
var quotes = [
"Whatever the mind of man can conceive and believe, it can achieve. –Napoleon Hill",
"You miss 100% of the shots you don’t take. –Wayne Gretzky",
];
$scope.getQuote = function () {
$scope.array = shuffle(quotes).slice(0, 1);
};
$scope.getQuote();
})
})();
view
<div class="col-md-6" ng-controller="ShuffleCtrl" onload="getQuote()">
<p ng-repeat="value in array">{{ value }}</p>
</div>
I have tried placing it outside the controller like the example I followed, and attempted using it as $scope.shuffle, but unfortunately, it does not seem to work. And yes, I have included body ng-app="TKC"