Essentially what I want are numbers that I can pass into HTML based on a the number of times substring is matched from a response body.
I understand the best way to get that number is through regex. If I were to look for the number of occurrences of 'RED' for example I would want something like:
var count1 = (proj.match(/RED/g) || []).length;
This is assuming that proj
is a var
with a response that has that in there.
Let's go with proj
having too occurrences of 'RED'.
count1
should equal '2' or so I believe it should. So I want this to be stored for use with AngularJS so I go:
$scope.red = count1;
And in the HTML I add {{red}}
. This however, does not show 2. It also does not break the AngularJS and the response is also fine.
Can anyone tell me where I'm going wrong?
$scope.red = 'foo'
, iffoo
is rendered, then your problem is angularjs, not regex. for angulrajs, post your html and controllers setup