Thank you for your patience. As a seasoned coder who has stuck to traditional methods for years, I am now diving into the world of AngularJS after putting off learning new technologies like JQuery. While going through tutorial videos and documentation, the terminology differences have posed a challenge for me. However, I'm determined to make progress by tackling real-world problems.
One such problem involves working with an array of Power Ball numbers and allowing users to input winning numbers in a space-delimited format, which would then be highlighted individually. I also plan to explore highlighting winning combinations differently. This exercise serves as a comprehensive test of my skills with various tools in AngularJS.
My questions are:
- Is my approach of initializing the array in the service and pushing values to it from the controller correct?
- Are my current practices, such as using ng-class, feasible if not entirely accurate?
- How can I utilize space-delimited input in the text box to compare and apply style changes?
Below is a snippet of my JavaScript code (note that only one set of numbers is included in the array):
var lotteryCheckApp = angular.module('lotteryCheckApp', []);
lotteryCheckApp.factory('PowerBall', function() {
var PowerBall = {};
PowerBall.numArray = ["42"];
PowerBall.myNumbers = [
{
First_Number: '03',
Second_Number: '07',
Third_Number: '17',
Fourth_Number: '21',
Fifth_Number: '42',
PowerBall: '21'
}
];
return PowerBall;
});
lotteryCheckApp.controller('PowerBallNumbersCtrl',function($scope,PowerBall) {
$scope.powerball = PowerBall;
$scope.winningStyle = true;
$scope.powerball.numArray.push("21");
$scope.myCheck = function(searchNum,numVal) {
// simple input-to-value comparison
if(searchNum == numVal) return true;
else return false;
}
}
Here is a link to my JSFiddle: http://jsfiddle.net/Divermarv/VpyxZ/1/
Thank you for your understanding and feedback.