0

I am trying to use angularJS along with Symfony2. For starters, m trying to display the object's text property as options in a simple dropdown list using ng-options. Here's the HTML

    <div ng-app="demoAddList" ng-controller="myCtrl">
    <select ng-model="selectedProgram"  ng-options="programofinterest.id as programofinterest.text for programofinterest in programofinterests">
            </select>
        </div>
<p>Try to add the same item twice, and you will get an error message.</p>

Here's the script

var app = angular.module("programDropdown", []);
app.controller("myCtrl", function($scope) {
        $scope.programofinterests = [
            {id: '0', text: 'Masters - Information Systems Management'},
            {id: '1', text: 'Masters - Software Engineering'},
            {id: '2', text: 'Masters - Computer Security'},
            {id: '3', text: 'Bachelors of Computer Science'},
            {id: '4', text: 'Exchange Program'},
            {id: '5', text: 'Study Abroad'},
            {id: '6', text: 'Scientific Summer School'},
            {id: '7', text: 'French Summer School'},
            {id: '8', text: 'ME - Global IT Management'},
            {id: '9', text: 'ME -  Software Development and Multimedia'},
            {id: '10', text: 'ME - Systems, Networks and Security'}
        ];
});

However the result is empty dropdown. Have a look at the top-left corner of the screenshot enter image description here

Any ideas?

2
  • 1
    You have not included jquery also the code need to be compiled since browser do not understand require keyword Commented Jun 27, 2016 at 6:28
  • are you talking about <script type="text/javascript" src="/EPITACRM/web/bundles/epitacrm/js/jquery-1.10.2.min.js"></script> ?? Commented Jun 27, 2016 at 6:43

1 Answer 1

1

First try to fix the "JQuery" and "require" issues. This will probably also fix your Angular issue, though not guaranteed since Angular normally does not need JQuery. It has a kind of lightweight JQuery embedded.

You might put a break-point in the controller and see if the debugger gets there.

Sign up to request clarification or add additional context in comments.

5 Comments

The debugger wasn't really inspecting the dropdown element.
I have no idea why the dropdown is not getting populated. Any idea if I've made any syntax mistake?
But the errors previously shown may prevent AngularJS to work properly. I really recommend fixing those issues first.
I tried copy pasting a simple AngularJS app from w3schools, in the same page, it worked just fine. M not sure why this isn't
Maybe you can try putting a break-point in your controller and see if it gets there. I still think you should sort out the JQuery and Require issues...

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.