0
我使用angularjs框架,我創建了一個form.html和一個controller.js與一個變量,檢索一個盒子的SSID。如何自動分配表單中變量的值。這是一個輸入字段。啓動應用程序時,表單應該自動顯示SSID,而用戶不需要這樣做。
$scope.SSID {}; return [object Oject] in input form ng-model="SSID"
謝謝你,請幫助我。
Controller.js
/*Controller*/
'use strict';
angular.module('djoro.controllers')
.controller('WifiSmartConfigCtrl', function($scope, $window, $ionicPlatform) {a
$scope.SSID = {};
$scope.getSSID = function() {
var onSuccess = function(SSID) {
$scope.SSID = SSID;
return SSID;
};
var onFail = function() {};
$ionicPlatform.ready(function() {
$window.cordova.plugins.Smartconfig.getSSID(onSuccess, onFail, $scope.SSID);
});
};
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.20/angular.min.js"></script>
<ion-pane>
<ion-header-bar class="bar-stable">
<h1 class="title">Ionic Blank Starter</h1>
</ion-header-bar>
<ion-content ng-controller="WifiSmartConfigCtrl">
<form novalidate class="simple-form">
<fieldset>
<legend>WI-FI</legend>
<div class="list input-fields">
<label class="item item-input">
<span class="input-label">SSID :</span>
<input type="text" name="test" ng-model="SSID" id="SSID" placeholder="SSID" required show-hide-input>
</label>
<label class="item item-input" show-hide-container>
<span class="input-label">Password :</span>
<input type="passwprd" name="test" placeholder="Password" required show-hide-input>
</label>
</div>
</fieldset>
</form>
</ion-content>
</ion-pane>
看起來你已經錯過了加入NG-應用指令。你應該這樣做 -。 –
Rabi