I'm trying to improve this JsFiddle code by adding Angular routes, controllers, services etc. http://jsfiddle.net/ProLoser/bp3Qu/light/
The problem I'm facing is with the following lines of code
function FormBuilderCtrl(){
var scope = this;
....
When I tried to convert the above to to this new fiddle http://jsfiddle.net/uhsarp/MdvQk/1/
function FormBuilderCtrl($scope){
...
Now everything breaks. I'm trying to understand what var scope=this meant and why passing the scope to the function isn't working.
Also, all the Angular directives are delcared as ng: instead of ng- (Example: ng:switch instead of ng-switch). Are they equivalent? Thanks.
Update:
I have followed the advise from the answers and upgraded the Angular version. I also removed var scope = this and injected the scope directly. http://plnkr.co/edit/Clr2T9V8J0z3oxW2HXur?p=preview
The only problem I now face is that whenever I change the field type from "text" to "radio buttons", I get an error (Line 45 in the script.js in the above plukr page)
TypeError: Cannot call method 'indexOf' of undefined
I checked the code but can't seem to be able to spot the problem.
var scope = thiswas an older Angular method for fetching scope and the new method is to have it passed as a parameter. Which is why your code would be messing up as it would be using an unsupported means for receiving the proper scope.