javascript - Can't seem to get ng-model to work in this instance -
<div class="col-lg-3"> <input type="text" id="hourhours" ng-model="hourhours" class="form-control" style="width: 60px" placeholder="hh" /> </div> <button type="button" class="btn" ng-click="addsubscriptionmodel()">submit</button>
here's simple html code ng-model. if type in 5 input, angular code should console.log out 5 it's still undefined...
var somecontroller = function ($scope, $modalinstance) { $scope.addsubscriptionmodel = function () { console.log($scope.hourhours); } });
edit: actual code... seems forgot mention i'm using tabset might why it's not working...
<tabset> <tab heading="hour" select="houroption()" ng-model="hour"> <div class="col-lg-3"> <input type="text" id="hourhours" ng-model="hourhours" class="form-control" style="width: 60px" placeholder="hh" /> </div> </tab> </tabset>
not quite seeing enough detail here, when page loads , populates data source typically need set properties on model [scope] initialize page. in short doing 2 way binding. if expect page populated before displaying in controller need set values on scope when controller executed. after enter new data page scope (or model), automatically updated on screen values.
update
as follow up. have learned judicious use of $compile
, $interpolate
can go long way solving problems like. allow perform late bindings scope. also, while still don't quite understand understand when use it, transclusion
can helpful.
Comments
Post a Comment