Angular: select

by HoffZ

HTML

<div ng-app>
    <div ng-controller="TestingCtrl">
         <h2>{{title}}</h2>

        <select ng-model="theChosenOne" ng-options="d.name for d in test.data">
            <!-- f.Arbeidsforholdid for f in arbeidstaker.AnsettelsesforholdListe -->
            <option value="">Choose</option>
        </select>
        
        <button ng-click="toggle()">Toggle</button>
    </div>
</div>

CSS

</style> <!-- Ugly Hack due to jsFiddle issue: http://goo.gl/BUfGZ --> <link rel="stylesheet" href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.0.4/css/bootstrap-combined.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.4/angular.min.js"></script> <style> .done-true {
    text-decoration: line-through;
    color: grey;
}

JavaScript

function TestingCtrl($scope) {
    $scope.title = 'Angular testing';

    $scope.test = {};    
    
    $scope.test.data = [{
        name: 'Olav',
        Age: 31
    }, {
        name: 'Nils',
        Age: 29
    } ];
    
    $scope.toggle = function() {
        
        $scope.theChosenOne = $scope.test.data[1];
    }
}