Since I've been trying to do my entire build process through Grunt I've had to rethink how testing works. Up until recently I've either been using Visual Studio plugins (Chutzpah or ReSharper) or Protractor as a macro in WebStorm. Both of these require a very specific configuration in order to run Jasmine tests. The same is true for setting up Jasmine testing in Grunt. However, what doesn't change is how to actually write the tests. Once you've got the configuration for your particular test harness setup this is how to structure tests.
A blog about coding in AngularJs, how different functionality works, and how to set up supporting technologies.
Sunday, 17 May 2015
Sunday, 3 May 2015
Use ngInit to Track $index in Nested ngRepeats
Recently some colleagues of mine were trying to do some conditional logic on an input element buried away in a couple of ngRepeats based on the index of the first ngRepeat. They were getting into a pickle using
$scope.$parent.$parent.$index
. When they were printing out the $index
it was giving them the answer they wanted, but then didn't behave in the same way when used within their logic on the input element. It turned out that this input was one $parent
further away and they querying the wrong scope. This is the time to use ngInit.
Location:
United Kingdom
Subscribe to:
Posts (Atom)